feat(analytics): add daily trend and activity heatmap endpoints, and implement corresponding frontend components

- Added new API endpoints for daily trend data and activity heatmap in analyticsRoutes.ts.
- Created new frontend components: ActivityChart, ControlBar, Heatmap, SummaryCards, TopicList, TrendChart, UserTable, and ViolatorTable for displaying analytics data.
- Implemented loading and empty states in the new components.
- Enhanced the existing moderation tests with remote fallback handling for Indonesian text normalization.
This commit is contained in:
MythEclipse
2026-05-31 00:41:34 +07:00
parent 4e9e370eb1
commit 71e240c1e7
21 changed files with 2130 additions and 1066 deletions
+44
View File
@@ -139,3 +139,47 @@ export async function fetchViolators(params: {
});
return request<ViolatorStat[]>(`/api/analytics/violators?${searchParams}`);
}
export interface TrendBucket {
date: string;
count: number;
clean: number;
warned: number;
flagged: number;
error: number;
}
export interface HeatmapCell {
dayOfWeek: number;
hour: number;
count: number;
clean: number;
warned: number;
flagged: number;
}
export async function fetchTrend(params: {
guildId: string;
channelId?: string;
hours?: number;
}): Promise<TrendBucket[]> {
const searchParams = new URLSearchParams({
guildId: params.guildId,
...(params.channelId && { channelId: params.channelId }),
...(params.hours && { hours: String(params.hours) }),
});
return request<TrendBucket[]>(`/api/analytics/trend?${searchParams}`);
}
export async function fetchHeatmap(params: {
guildId: string;
channelId?: string;
hours?: number;
}): Promise<HeatmapCell[]> {
const searchParams = new URLSearchParams({
guildId: params.guildId,
...(params.channelId && { channelId: params.channelId }),
...(params.hours && { hours: String(params.hours) }),
});
return request<HeatmapCell[]>(`/api/analytics/heatmap?${searchParams}`);
}