feat(数据看板): 将评论趋势统计从7天改为30天

修改前端展示、API文档和后端逻辑,将评论趋势统计的时间范围从7天扩展至30天,以提供更全面的数据分析视角
This commit is contained in:
anghunk
2026-01-21 22:01:14 +08:00
parent d5a7a15344
commit 73eaa975fe
3 changed files with 6 additions and 6 deletions

View File

@@ -94,12 +94,12 @@ export const getStats = async (c: Context<{ Bindings: Bindings }>) => {
.sort((a, b) => b.total - a.total);
const now = Date.now();
const sevenDaysAgo = now - 6 * 24 * 60 * 60 * 1000;
const thirtyDaysAgo = now - 29 * 24 * 60 * 60 * 1000;
const { results: dailyRows } = await c.env.CWD_DB.prepare(
"SELECT date(created / 1000, 'unixepoch') as day, COUNT(*) as total FROM Comment WHERE created >= ? GROUP BY day ORDER BY day ASC"
)
.bind(sevenDaysAgo)
.bind(thirtyDaysAgo)
.all<{ day: string; total: number }>();
const dailyMap = new Map<string, number>();
@@ -110,7 +110,7 @@ export const getStats = async (c: Context<{ Bindings: Bindings }>) => {
}
const last7Days: { date: string; total: number }[] = [];
for (let i = 6; i >= 0; i--) {
for (let i = 29; i >= 0; i--) {
const d = new Date(now - i * 24 * 60 * 60 * 1000);
const year = d.getUTCFullYear();
const month = String(d.getUTCMonth() + 1).padStart(2, '0');