From 71998caef9f1994e3f50892359351d20525f6876 Mon Sep 17 00:00:00 2001 From: goenning Date: Tue, 28 Dec 2021 14:46:44 +0000 Subject: [PATCH] remove unecessary http request when running all checks Signed-off-by: goenning --- plugins/tech-insights/src/api/TechInsightsClient.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index 43979e60b0..e69fb5ceeb 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -66,20 +66,20 @@ export class TechInsightsClient implements TechInsightsApi { async runChecks( entityParams: EntityName, - checks: Check[], + checks?: Check[], ): Promise { const url = await this.discoveryApi.getBaseUrl('tech-insights'); const token = await this.identityApi.getIdToken(); const { namespace, kind, name } = entityParams; - const allChecks = checks ? checks : await this.getAllChecks(); - const checkIds = allChecks.map((check: Check) => check.id); + const checkIds = checks ? checks.map((check: Check) => check.id) : []; + const requestBody = { checks: checkIds.length > 0 ? checkIds : null }; const response = await fetch( `${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent( kind, )}/${encodeURIComponent(name)}`, { method: 'POST', - body: JSON.stringify({ checks: checkIds }), + body: JSON.stringify(requestBody), headers: { 'Content-Type': 'application/json', ...(token && { Authorization: `Bearer ${token}` }),