diff options
| author | Dhravya Shah <[email protected]> | 2024-08-03 18:31:55 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-08-03 18:31:55 -0700 |
| commit | a327805a7d668bfa928564783e80a30adef96f88 (patch) | |
| tree | 0e682f238812b2ce663f6b82c01a8be30a1b29f3 /apps | |
| parent | fix: stuff (diff) | |
| download | supermemory-a327805a7d668bfa928564783e80a30adef96f88.tar.xz supermemory-a327805a7d668bfa928564783e80a30adef96f88.zip | |
calculate how fucked we are
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/cf-ai-backend/src/index.ts | 41 | ||||
| -rw-r--r-- | apps/web/app/api/telegram/route.ts | 4 |
2 files changed, 43 insertions, 2 deletions
diff --git a/apps/cf-ai-backend/src/index.ts b/apps/cf-ai-backend/src/index.ts index 6b900582..70d282d9 100644 --- a/apps/cf-ai-backend/src/index.ts +++ b/apps/cf-ai-backend/src/index.ts @@ -666,4 +666,45 @@ app.get( }, ); +app.get("/howFuckedAreWe", async (c) => { + let keys = 0; + const concurrencyLimit = 5; // Adjust this based on your system's capability + const queue: string[] = [undefined]; // Start with an undefined cursor + + async function fetchKeys(cursor?: string): Promise<void> { + const response = await c.env.KV.list({ cursor }); + keys += response.keys.length; + + // @ts-ignore + if (response.cursor) { + // @ts-ignore + queue.push(response.cursor); + } + } + + async function getAllKeys(): Promise<void> { + const promises: Promise<void>[] = []; + + while (queue.length > 0) { + while (promises.length < concurrencyLimit && queue.length > 0) { + const cursor = queue.shift(); + promises.push(fetchKeys(cursor)); + } + + await Promise.all(promises); + promises.length = 0; // Clear the promises array + } + } + + await getAllKeys(); + + console.log(`Total number of keys: ${keys}`); + + // on a scale of 200,000 + // what % are we there? + const fuckedPercent = (keys / 200000) * 100; + + return c.json({ fuckedPercent }); +}); + export default app; diff --git a/apps/web/app/api/telegram/route.ts b/apps/web/app/api/telegram/route.ts index 78837e5f..06499c7d 100644 --- a/apps/web/app/api/telegram/route.ts +++ b/apps/web/app/api/telegram/route.ts @@ -68,9 +68,9 @@ bot.on("message", async (ctx) => { if (response.status !== 200) { console.log("Failed to get response from backend"); console.log(response.status); - console.log(await response.text()); await ctx.reply( - "Sorry, I am not able to process your request at the moment.", + "Sorry, I am not able to process your request at the moment." + + (await response.text()), ); return; } |