Add team and stream counts to footer
- Created /api/counts endpoint for database statistics - Updated footer to display team and stream counts - Shows counts when OBS is connected (alongside OBS stats) - Shows database stats when OBS is disconnected (fallback display) - Polls counts every 60 seconds (less frequent than OBS status) - Maintains backward compatibility with API response formats Footer now shows: - Teams: X - Streams: Y 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cbf8cd6516
commit
02cad6a319
2 changed files with 83 additions and 7 deletions
25
app/api/counts/route.ts
Normal file
25
app/api/counts/route.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
import { getDatabase } from '../../../lib/database';
|
||||
import { TABLE_NAMES } from '../../../lib/constants';
|
||||
import { createSuccessResponse, createDatabaseError, withErrorHandling } from '../../../lib/apiHelpers';
|
||||
|
||||
async function getCountsHandler() {
|
||||
try {
|
||||
const db = await getDatabase();
|
||||
|
||||
// Get counts in parallel
|
||||
const [streamsResult, teamsResult] = await Promise.all([
|
||||
db.get(`SELECT COUNT(*) as count FROM ${TABLE_NAMES.STREAMS}`),
|
||||
db.get(`SELECT COUNT(*) as count FROM ${TABLE_NAMES.TEAMS}`)
|
||||
]);
|
||||
|
||||
return createSuccessResponse({
|
||||
streams: streamsResult.count,
|
||||
teams: teamsResult.count
|
||||
});
|
||||
} catch (error) {
|
||||
return createDatabaseError('fetch counts', error);
|
||||
}
|
||||
}
|
||||
|
||||
export const GET = withErrorHandling(getCountsHandler);
|
Loading…
Add table
Add a link
Reference in a new issue