Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: omit release details to speed up lib search #1949

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"version": {
"owner": "arduino",
"repo": "arduino-cli",
"commitish": "6992de7"
"commitish": "71a8576"
}
},
"fwuploader": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ export class LibrarySearchRequest extends jspb.Message {
getQuery(): string;
setQuery(value: string): LibrarySearchRequest;

getOmitReleasesDetails(): boolean;
setOmitReleasesDetails(value: boolean): LibrarySearchRequest;


serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibrarySearchRequest.AsObject;
Expand All @@ -421,6 +424,7 @@ export namespace LibrarySearchRequest {
export type AsObject = {
instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject,
query: string,
omitReleasesDetails: boolean,
}
}

Expand Down Expand Up @@ -465,6 +469,11 @@ export class SearchedLibrary extends jspb.Message {
getLatest(): LibraryRelease | undefined;
setLatest(value?: LibraryRelease): SearchedLibrary;

clearAvailableVersionsList(): void;
getAvailableVersionsList(): Array<string>;
setAvailableVersionsList(value: Array<string>): SearchedLibrary;
addAvailableVersions(value: string, index?: number): string;


serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SearchedLibrary.AsObject;
Expand All @@ -482,6 +491,7 @@ export namespace SearchedLibrary {

releasesMap: Array<[string, LibraryRelease.AsObject]>,
latest?: LibraryRelease.AsObject,
availableVersionsList: Array<string>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
jspb.Message.initialize(this, opt_data, 0, -1, proto.cc.arduino.cli.commands.v1.SearchedLibrary.repeatedFields_, null);
};
goog.inherits(proto.cc.arduino.cli.commands.v1.SearchedLibrary, jspb.Message);
if (goog.DEBUG && !COMPILED) {
Expand Down Expand Up @@ -3202,7 +3202,8 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.toObject = funct
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.toObject = function(includeInstance, msg) {
var f, obj = {
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f),
query: jspb.Message.getFieldWithDefault(msg, 2, "")
query: jspb.Message.getFieldWithDefault(msg, 2, ""),
omitReleasesDetails: jspb.Message.getBooleanFieldWithDefault(msg, 3, false)
};

if (includeInstance) {
Expand Down Expand Up @@ -3248,6 +3249,10 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.deserializeBinaryFromReade
var value = /** @type {string} */ (reader.readString());
msg.setQuery(value);
break;
case 3:
var value = /** @type {boolean} */ (reader.readBool());
msg.setOmitReleasesDetails(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -3292,6 +3297,13 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.serializeBinaryToWriter =
f
);
}
f = message.getOmitReleasesDetails();
if (f) {
writer.writeBool(
3,
f
);
}
};


Expand Down Expand Up @@ -3350,6 +3362,24 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.setQuery = funct
};


/**
* optional bool omit_releases_details = 3;
* @return {boolean}
*/
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.getOmitReleasesDetails = function() {
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false));
};


/**
* @param {boolean} value
* @return {!proto.cc.arduino.cli.commands.v1.LibrarySearchRequest} returns this
*/
proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.prototype.setOmitReleasesDetails = function(value) {
return jspb.Message.setProto3BooleanField(this, 3, value);
};



/**
* List of repeated fields within this message type.
Expand Down Expand Up @@ -3541,6 +3571,13 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchResponse.prototype.setStatus = fun



/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary.repeatedFields_ = [4];



if (jspb.Message.GENERATE_TO_OBJECT) {
Expand Down Expand Up @@ -3574,7 +3611,8 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.toObject = function(includeInst
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
releasesMap: (f = msg.getReleasesMap()) ? f.toObject(includeInstance, proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject) : [],
latest: (f = msg.getLatest()) && proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject(includeInstance, f)
latest: (f = msg.getLatest()) && proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject(includeInstance, f),
availableVersionsList: (f = jspb.Message.getRepeatedField(msg, 4)) == null ? undefined : f
};

if (includeInstance) {
Expand Down Expand Up @@ -3626,6 +3664,10 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.deserializeBinaryFromReader = f
reader.readMessage(value,proto.cc.arduino.cli.commands.v1.LibraryRelease.deserializeBinaryFromReader);
msg.setLatest(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.addAvailableVersions(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -3674,6 +3716,13 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.serializeBinaryToWriter = funct
proto.cc.arduino.cli.commands.v1.LibraryRelease.serializeBinaryToWriter
);
}
f = message.getAvailableVersionsList();
if (f.length > 0) {
writer.writeRepeatedString(
4,
f
);
}
};


Expand Down Expand Up @@ -3754,6 +3803,43 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.hasLatest = function(
};


/**
* repeated string available_versions = 4;
* @return {!Array<string>}
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.getAvailableVersionsList = function() {
return /** @type {!Array<string>} */ (jspb.Message.getRepeatedField(this, 4));
};


/**
* @param {!Array<string>} value
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.setAvailableVersionsList = function(value) {
return jspb.Message.setField(this, 4, value || []);
};


/**
* @param {string} value
* @param {number=} opt_index
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.addAvailableVersions = function(value, opt_index) {
return jspb.Message.addToRepeatedField(this, 4, value, opt_index);
};


/**
* Clears the list making it empty but non-null.
* @return {!proto.cc.arduino.cli.commands.v1.SearchedLibrary} returns this
*/
proto.cc.arduino.cli.commands.v1.SearchedLibrary.prototype.clearAvailableVersionsList = function() {
return this.setAvailableVersionsList([]);
};



/**
* List of repeated fields within this message type.
Expand Down
6 changes: 2 additions & 4 deletions arduino-ide-extension/src/node/library-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class LibraryServiceImpl
const req = new LibrarySearchRequest();
req.setQuery(options.query || '');
req.setInstance(instance);
req.setOmitReleasesDetails(true);
const resp = await new Promise<LibrarySearchResponse>((resolve, reject) =>
client.librarySearch(req, (err, resp) =>
!!err ? reject(err) : resolve(resp)
Expand All @@ -88,11 +89,8 @@ export class LibraryServiceImpl
.getLibrariesList()
.filter((item) => !!item.getLatest())
.map((item) => {
// TODO: This seems to contain only the latest item instead of all of the items.
const availableVersions = item
.getReleasesMap()
.getEntryList()
.map(([key, _]) => key)
.getAvailableVersionsList()
.sort(Installable.Version.COMPARATOR)
.reverse();
let installedVersion: string | undefined;
Expand Down