Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions apps/workflows/src/workflows/count_keys_per_keyspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class CountKeys extends WorkflowEntrypoint<Env, Params> {
password: this.env.DATABASE_PASSWORD,
});


await step.do("fetch keyspaces", async () => {
const keySpaces = await db.query.keyAuth.findMany({
where: (table, { or, and, isNull, lt }) =>
Expand All @@ -32,18 +31,22 @@ export class CountKeys extends WorkflowEntrypoint<Env, Params> {
console.info(`found ${keySpaces.length} key spaces`);

for (const keySpace of keySpaces) {
const rows = await step.do(`count keys for ${keySpace.id} `, async () => db
.select({ count: count() })
.from(schema.keys)
.where(and(eq(schema.keys.keyAuthId, keySpace.id), isNull(schema.keys.deletedAt))))

await step.do(`update ${keySpace.id}`, async () => db
.update(schema.keyAuth)
.set({
sizeApprox: rows.at(0)?.count ?? 0,
sizeLastUpdatedAt: Date.now(),
})
.where(eq(schema.keyAuth.id, keySpace.id)))
const rows = await step.do(`count keys for ${keySpace.id} `, async () =>
db
.select({ count: count() })
.from(schema.keys)
.where(and(eq(schema.keys.keyAuthId, keySpace.id), isNull(schema.keys.deletedAt))),
);

await step.do(`update ${keySpace.id}`, async () =>
db
.update(schema.keyAuth)
.set({
sizeApprox: rows.at(0)?.count ?? 0,
sizeLastUpdatedAt: Date.now(),
})
.where(eq(schema.keyAuth.id, keySpace.id)),
);
}
// this just prints on the cf dashboard, we don't use the return value
return { keySpaces: keySpaces.length };
Expand Down
5 changes: 5 additions & 0 deletions apps/www/components/footer/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const navigation = [
title: "Glossary",
href: "/glossary",
},
{
title: "Status Page",
href: "https://status.unkey.com",
external: true,
},
],
},
{
Expand Down