feat: omit release details to speed up lib search

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2023-03-10 15:28:53 +01:00 committed by Akos Kitta
parent 0ab28266df
commit 9b49712669
4 changed files with 102 additions and 8 deletions

View File

@ -166,7 +166,7 @@
"version": { "version": {
"owner": "arduino", "owner": "arduino",
"repo": "arduino-cli", "repo": "arduino-cli",
"commitish": "6992de7" "commitish": "71a8576"
} }
}, },
"fwuploader": { "fwuploader": {

View File

@ -406,6 +406,9 @@ export class LibrarySearchRequest extends jspb.Message {
getQuery(): string; getQuery(): string;
setQuery(value: string): LibrarySearchRequest; setQuery(value: string): LibrarySearchRequest;
getOmitReleasesDetails(): boolean;
setOmitReleasesDetails(value: boolean): LibrarySearchRequest;
serializeBinary(): Uint8Array; serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): LibrarySearchRequest.AsObject; toObject(includeInstance?: boolean): LibrarySearchRequest.AsObject;
@ -421,6 +424,7 @@ export namespace LibrarySearchRequest {
export type AsObject = { export type AsObject = {
instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject, instance?: cc_arduino_cli_commands_v1_common_pb.Instance.AsObject,
query: string, query: string,
omitReleasesDetails: boolean,
} }
} }
@ -465,6 +469,11 @@ export class SearchedLibrary extends jspb.Message {
getLatest(): LibraryRelease | undefined; getLatest(): LibraryRelease | undefined;
setLatest(value?: LibraryRelease): SearchedLibrary; setLatest(value?: LibraryRelease): SearchedLibrary;
clearAvailableVersionsList(): void;
getAvailableVersionsList(): Array<string>;
setAvailableVersionsList(value: Array<string>): SearchedLibrary;
addAvailableVersions(value: string, index?: number): string;
serializeBinary(): Uint8Array; serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): SearchedLibrary.AsObject; toObject(includeInstance?: boolean): SearchedLibrary.AsObject;
@ -482,6 +491,7 @@ export namespace SearchedLibrary {
releasesMap: Array<[string, LibraryRelease.AsObject]>, releasesMap: Array<[string, LibraryRelease.AsObject]>,
latest?: LibraryRelease.AsObject, latest?: LibraryRelease.AsObject,
availableVersionsList: Array<string>,
} }
} }

View File

@ -374,7 +374,7 @@ if (goog.DEBUG && !COMPILED) {
* @constructor * @constructor
*/ */
proto.cc.arduino.cli.commands.v1.SearchedLibrary = function(opt_data) { 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); goog.inherits(proto.cc.arduino.cli.commands.v1.SearchedLibrary, jspb.Message);
if (goog.DEBUG && !COMPILED) { if (goog.DEBUG && !COMPILED) {
@ -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) { proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.toObject = function(includeInstance, msg) {
var f, obj = { var f, obj = {
instance: (f = msg.getInstance()) && cc_arduino_cli_commands_v1_common_pb.Instance.toObject(includeInstance, f), 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) { if (includeInstance) {
@ -3248,6 +3249,10 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.deserializeBinaryFromReade
var value = /** @type {string} */ (reader.readString()); var value = /** @type {string} */ (reader.readString());
msg.setQuery(value); msg.setQuery(value);
break; break;
case 3:
var value = /** @type {boolean} */ (reader.readBool());
msg.setOmitReleasesDetails(value);
break;
default: default:
reader.skipField(); reader.skipField();
break; break;
@ -3292,6 +3297,13 @@ proto.cc.arduino.cli.commands.v1.LibrarySearchRequest.serializeBinaryToWriter =
f f
); );
} }
f = message.getOmitReleasesDetails();
if (f) {
writer.writeBool(
3,
f
);
}
}; };
@ -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. * List of repeated fields within this message type.
@ -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) { if (jspb.Message.GENERATE_TO_OBJECT) {
@ -3574,7 +3611,8 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.toObject = function(includeInst
var f, obj = { var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""), name: jspb.Message.getFieldWithDefault(msg, 1, ""),
releasesMap: (f = msg.getReleasesMap()) ? f.toObject(includeInstance, proto.cc.arduino.cli.commands.v1.LibraryRelease.toObject) : [], 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) { if (includeInstance) {
@ -3626,6 +3664,10 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.deserializeBinaryFromReader = f
reader.readMessage(value,proto.cc.arduino.cli.commands.v1.LibraryRelease.deserializeBinaryFromReader); reader.readMessage(value,proto.cc.arduino.cli.commands.v1.LibraryRelease.deserializeBinaryFromReader);
msg.setLatest(value); msg.setLatest(value);
break; break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.addAvailableVersions(value);
break;
default: default:
reader.skipField(); reader.skipField();
break; break;
@ -3674,6 +3716,13 @@ proto.cc.arduino.cli.commands.v1.SearchedLibrary.serializeBinaryToWriter = funct
proto.cc.arduino.cli.commands.v1.LibraryRelease.serializeBinaryToWriter proto.cc.arduino.cli.commands.v1.LibraryRelease.serializeBinaryToWriter
); );
} }
f = message.getAvailableVersionsList();
if (f.length > 0) {
writer.writeRepeatedString(
4,
f
);
}
}; };
@ -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. * List of repeated fields within this message type.

View File

@ -79,6 +79,7 @@ export class LibraryServiceImpl
const req = new LibrarySearchRequest(); const req = new LibrarySearchRequest();
req.setQuery(options.query || ''); req.setQuery(options.query || '');
req.setInstance(instance); req.setInstance(instance);
req.setOmitReleasesDetails(true);
const resp = await new Promise<LibrarySearchResponse>((resolve, reject) => const resp = await new Promise<LibrarySearchResponse>((resolve, reject) =>
client.librarySearch(req, (err, resp) => client.librarySearch(req, (err, resp) =>
!!err ? reject(err) : resolve(resp) !!err ? reject(err) : resolve(resp)
@ -88,11 +89,8 @@ export class LibraryServiceImpl
.getLibrariesList() .getLibrariesList()
.filter((item) => !!item.getLatest()) .filter((item) => !!item.getLatest())
.map((item) => { .map((item) => {
// TODO: This seems to contain only the latest item instead of all of the items.
const availableVersions = item const availableVersions = item
.getReleasesMap() .getAvailableVersionsList()
.getEntryList()
.map(([key, _]) => key)
.sort(Installable.Version.COMPARATOR) .sort(Installable.Version.COMPARATOR)
.reverse(); .reverse();
let installedVersion: string | undefined; let installedVersion: string | undefined;