diff --git a/services/backend/src/modules/dashboard/dashboard.repository.ts b/services/backend/src/modules/dashboard/dashboard.repository.ts index ef94079..229f9ef 100644 --- a/services/backend/src/modules/dashboard/dashboard.repository.ts +++ b/services/backend/src/modules/dashboard/dashboard.repository.ts @@ -42,9 +42,11 @@ export class DashboardRepository { // Top channels by message count const topChannels = await pool.query(` - SELECT channel_id, COUNT(*)::int AS message_count + SELECT channel_id, + (metadata::jsonb -> 'channel' ->> 'channelName') AS channel_name, + COUNT(*)::int AS message_count FROM messages - GROUP BY channel_id + GROUP BY channel_id, (metadata::jsonb -> 'channel' ->> 'channelName') ORDER BY COUNT(*) DESC LIMIT 10 `); @@ -63,6 +65,7 @@ export class DashboardRepository { active_users_24h: msgRow?.active_users_24h ?? 0, top_channels: topChannels.rows.map((r: Record) => ({ channel_id: String(r.channel_id), + channel_name: r.channel_name ? String(r.channel_name) : null, message_count: Number(r.message_count), })), moderation_overview: { diff --git a/services/frontend/src/features/dashboard/components/DashboardStats.tsx b/services/frontend/src/features/dashboard/components/DashboardStats.tsx index ff1518c..d4011f8 100644 --- a/services/frontend/src/features/dashboard/components/DashboardStats.tsx +++ b/services/frontend/src/features/dashboard/components/DashboardStats.tsx @@ -161,8 +161,8 @@ export function DashboardStatsContent() { key={ch.channel_id} className="flex items-center justify-between rounded-lg bg-muted/50 px-3 py-2 text-sm" > - - #{ch.channel_id} + + #{ch.channel_name ?? ch.channel_id} {ch.message_count.toLocaleString()} diff --git a/services/frontend/src/shared/api/client.ts b/services/frontend/src/shared/api/client.ts index f14ad6e..a0f8ce8 100644 --- a/services/frontend/src/shared/api/client.ts +++ b/services/frontend/src/shared/api/client.ts @@ -281,7 +281,7 @@ export interface DashboardStats { today_messages: number; today_flagged: number; active_users_24h: number; - top_channels: Array<{ channel_id: string; message_count: number }>; + top_channels: Array<{ channel_id: string; channel_name: string | null; message_count: number }>; moderation_overview: { pending: number; processing: number;