From 4e2028456654f6b1c9805e5f6a3d8f57b60e7037 Mon Sep 17 00:00:00 2001 From: "Zee V. (Philip)" Date: Tue, 7 Jun 2022 10:34:42 +0200 Subject: [PATCH] refactor: clean up construction of opts Signed-off-by: Zee V. (Philip) --- .../src/GitLabDiscoveryProcessor.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts index a23d1f2803..25240d2d14 100644 --- a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts +++ b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.ts @@ -100,20 +100,13 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor { }); this.logger.debug(`Reading GitLab projects from ${location.target}`); + const lastActivity = (await this.cache.get(this.getCacheKey())) as string; const opts = { group, page: 1, - } as { - group: string; - page: number; - last_activity_after: string | undefined; - }; - - const lastActivity = (await this.cache.get(this.getCacheKey())) as string; - // We check for the existence of lastActivity and only set it if it's present to ensure - // that the options doesn't include the key so that the API doesn't receive an empty query parameter. - if (lastActivity) { - opts.last_activity_after = lastActivity; + // We check for the existence of lastActivity and only set it if it's present to ensure + // that the options doesn't include the key so that the API doesn't receive an empty query parameter. + ...(lastActivity && { last_activity_after: lastActivity }), } const projects = paginated(options => client.listProjects(options), opts);