From 156bfb2ecf569480346a3cb3f372f7fa6c025f91 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:09:36 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- ...1_analytics_getVerifications.happy.test.ts | 37 +++++++++---------- .../routes/v1_analytics_getVerifications.ts | 15 +++----- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/apps/api/src/routes/v1_analytics_getVerifications.happy.test.ts b/apps/api/src/routes/v1_analytics_getVerifications.happy.test.ts index 8832a7425..003052d91 100644 --- a/apps/api/src/routes/v1_analytics_getVerifications.happy.test.ts +++ b/apps/api/src/routes/v1_analytics_getVerifications.happy.test.ts @@ -541,22 +541,21 @@ describe("RFC scenarios", () => { h.createKey(), ]); - const now = Date.now() - - - - const tags = [["a", "b"], ["a"], [], ["b", "c"]] - - const verifications = tags.flatMap(tags => generate({ - start: now - 60 * 24 * 60 * 60 * 1000, - end: now, - length: 100_000, - workspaceId: h.resources.userWorkspace.id, - keySpaceId: h.resources.userKeyAuth.id, - keys: keys.map((k) => ({ keyId: k.keyId, identityId: k.identityId })), - tags + const now = Date.now(); - })) + const tags = [["a", "b"], ["a"], [], ["b", "c"]]; + + const verifications = tags.flatMap((tags) => + generate({ + start: now - 60 * 24 * 60 * 60 * 1000, + end: now, + length: 100_000, + workspaceId: h.resources.userWorkspace.id, + keySpaceId: h.resources.userKeyAuth.id, + keys: keys.map((k) => ({ keyId: k.keyId, identityId: k.identityId })), + tags, + }), + ); await h.ch.verifications.insert(verifications); @@ -599,7 +598,7 @@ describe("RFC scenarios", () => { }, ); - console.table(res.body) + console.table(res.body); expect(res.body.reduce((sum, d) => sum + d.total, 0)).toEqual(total); expect(res.body.reduce((sum, d) => sum + (d.valid ?? 0), 0)).toEqual(outcomes.VALID); @@ -642,17 +641,15 @@ describe("RFC scenarios", () => { keys: keys.map((k) => ({ keyId: k.keyId, identityId: k.identityId })), }); - const start = now - 30 * 24 * 60 * 60 * 1000; const end = now; - await h.ch.verifications.insert(verifications); const byIdentity = verifications.reduce( (acc, v) => { if (toStartOfHour(v.time) < start || toStartOfHour(v.time) > end) { - return acc + return acc; } if (!acc[v.identity_id!]) { acc[v.identity_id!] = { @@ -764,5 +761,5 @@ function generate(opts: { } function toStartOfHour(unixmilli: number): number { - return Math.floor(unixmilli / 60 / 60 / 1000) * 60 * 60 * 1000 + return Math.floor(unixmilli / 60 / 60 / 1000) * 60 * 60 * 1000; } diff --git a/apps/api/src/routes/v1_analytics_getVerifications.ts b/apps/api/src/routes/v1_analytics_getVerifications.ts index 86331d48e..7366ec62c 100644 --- a/apps/api/src/routes/v1_analytics_getVerifications.ts +++ b/apps/api/src/routes/v1_analytics_getVerifications.ts @@ -18,11 +18,9 @@ const route = createRoute({ security: [{ bearerAuth: [] }], request: { query: z.object({ - apiId: z - .string() - .openapi({ - description: "Select the API. Only keys belonging to this API will be included.", - }), + apiId: z.string().openapi({ + description: "Select the API. Only keys belonging to this API will be included.", + }), externalId: z.string().optional().openapi({ description: "Filtering by externalId allows you to narrow down the search to a specific user or organisation.", @@ -251,7 +249,6 @@ STEP INTERVAL 1 MONTH`, table = tables.hour; } - if (selectedGroupBy.includes("key")) { select.push("key_id AS keyId"); groupBy.push("key_id"); @@ -417,9 +414,9 @@ STEP INTERVAL 1 MONTH`, tags: row.tags, identity: row.identityId ? { - id: row.identityId, - externalId: "TODO", - } + id: row.identityId, + externalId: "TODO", + } : undefined, })), );