···11111212export async function GET(request: NextRequest) {
1313 try {
1414+ // Define the plumber's DID - this is the official plumber account DID
1515+ const PLUMBER_DID = 'did:plc:fouf3svmcxzn6bpiw3lgwz22';
1616+1717+ // List of DIDs to exclude from leaderboard
1818+ const excludedDids = [
1919+ PLUMBER_DID, // plumber.flushes.app (formerly plumber.flushing.im)
2020+ 'did:plc:fnhrjbkwjiw6iyxxg2o3rljw' // testing.dame.is
2121+ ];
2222+2323+ // List of handles to exclude from leaderboard (as fallback)
2424+ // Include both the old and new plumber handles for backward compatibility
2525+ const excludedHandles = [
2626+ 'plumber.flushes.app', // New plumber handle
2727+ 'plumber.flushing.im', // Old plumber handle (for backward compatibility)
2828+ 'testing.dame.is'
2929+ ];
3030+1431 // If we have Supabase credentials, fetch stats
1532 if (supabaseUrl && supabaseKey) {
1633 const supabase = createClient(supabaseUrl, supabaseKey);
···94111 // 2. Get daily flush counts for the chart
95112 const { data: dailyData, error: dailyError } = await supabase
96113 .from('flushing_records')
9797- .select('created_at, did')
114114+ .select('created_at, did, handle')
98115 .order('created_at', { ascending: true });
99116100117 if (dailyError) {
···144161 const recentUniqueDids = new Set<string>();
145162 recentRecords?.forEach(entry => {
146163 // Only count if not an excluded account
147147- if (entry.did &&
148148- !excludedDids.includes(entry.did) &&
149149- !(entry.handle && excludedHandles.includes(entry.handle))) {
164164+ const isExcludedDid = entry.did && excludedDids.includes(entry.did);
165165+ const isExcludedHandle = entry.handle && typeof entry.handle === 'string' && excludedHandles.includes(entry.handle);
166166+167167+ if (entry.did && !isExcludedDid && !isExcludedHandle) {
150168 recentUniqueDids.add(entry.did);
151169 }
152170 });
···163181 if (!entry.did) return; // Skip entries without a DID
164182165183 // Skip excluded accounts
166166- if (excludedDids.includes(entry.did) ||
167167- (entry.handle && excludedHandles.includes(entry.handle))) {
184184+ const isExcludedDid = excludedDids.includes(entry.did);
185185+ const isExcludedHandle = entry.handle && typeof entry.handle === 'string' && excludedHandles.includes(entry.handle);
186186+187187+ if (isExcludedDid || isExcludedHandle) {
168188 return;
169189 }
170190···211231212232 // Special count for the plumber account
213233 let plumberFlushCount = 0;
214214-215215- // Define the plumber's DID - this is the official plumber account DID
216216- const PLUMBER_DID = 'did:plc:fouf3svmcxzn6bpiw3lgwz22';
217217-218218- // List of DIDs to exclude from leaderboard
219219- const excludedDids = [
220220- PLUMBER_DID, // plumber.flushes.app (formerly plumber.flushing.im)
221221- 'did:plc:fnhrjbkwjiw6iyxxg2o3rljw' // testing.dame.is
222222- ];
223223-224224- // List of handles to exclude from leaderboard (as fallback)
225225- // Include both the old and new plumber handles for backward compatibility
226226- const excludedHandles = [
227227- 'plumber.flushes.app', // New plumber handle
228228- 'plumber.flushing.im', // Old plumber handle (for backward compatibility)
229229- 'testing.dame.is'
230230- ];
231234232235 leaderboardData?.forEach(entry => {
233236 // Check if this is the plumber account (by DID or either handle)