Webhooks for the AT Protocol airglow.run
atproto atprotocol automation webhook
12
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: automation count per lexicon

Hugo 4ee836cf 2a0a63b2

+16 -1
+16 -1
app/routes/u/[handle]/index.tsx
··· 1 1 import { createRoute } from "honox/factory"; 2 - import { eq } from "drizzle-orm"; 2 + import { eq, inArray, count } from "drizzle-orm"; 3 3 import { Eye, Zap, Globe } from "../../../icons.js"; 4 4 import { getSessionUser } from "@/auth/middleware.js"; 5 5 import { resolveHandle } from "@/auth/client.js"; ··· 57 57 await collectCachedNsids(nsidPrefix, lexiconResults); 58 58 await collectRemoteNsids(nsidPrefix, lexiconResults); 59 59 const lexicons = [...lexiconResults].filter((nsid) => nsid.startsWith(nsidPrefix)).sort(); 60 + 61 + // Count automations subscribed to each lexicon 62 + const subCounts = new Map<string, number>(); 63 + if (lexicons.length > 0) { 64 + const rows = await db 65 + .select({ lexicon: automations.lexicon, count: count() }) 66 + .from(automations) 67 + .where(inArray(automations.lexicon, lexicons)) 68 + .groupBy(automations.lexicon); 69 + for (const row of rows) { 70 + subCounts.set(row.lexicon, row.count); 71 + } 72 + } 60 73 61 74 // 404 if nothing to show 62 75 if (autos.length === 0 && lexicons.length === 0) { ··· 171 184 <thead> 172 185 <tr> 173 186 <th>NSID</th> 187 + <th>Automations</th> 174 188 </tr> 175 189 </thead> 176 190 <tbody> ··· 181 195 <InlineCode>{nsid}</InlineCode> 182 196 </a> 183 197 </td> 198 + <td>{subCounts.get(nsid) ?? 0}</td> 184 199 </tr> 185 200 ))} 186 201 </tbody>