Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jan 8, 2025
1 parent 39e855c commit 156bfb2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
37 changes: 17 additions & 20 deletions apps/api/src/routes/v1_analytics_getVerifications.happy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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!] = {
Expand Down Expand Up @@ -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;
}
15 changes: 6 additions & 9 deletions apps/api/src/routes/v1_analytics_getVerifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
})),
);
Expand Down

0 comments on commit 156bfb2

Please sign in to comment.