mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-04-23 18:19:01 +08:00
feat: 新增视图Tab
This commit is contained in:
@@ -242,6 +242,37 @@ export function getMonthlyActivity(sessionId: string, filter?: TimeFilter): any[
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年份活跃度分布
|
||||
*/
|
||||
export function getYearlyActivity(sessionId: string, filter?: TimeFilter): any[] {
|
||||
const db = openDatabase(sessionId)
|
||||
if (!db) return []
|
||||
|
||||
const { clause, params } = buildTimeFilter(filter)
|
||||
const clauseWithSystem = buildSystemMessageFilter(clause)
|
||||
|
||||
const rows = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT
|
||||
CAST(strftime('%Y', msg.ts, 'unixepoch', 'localtime') AS INTEGER) as year,
|
||||
COUNT(*) as messageCount
|
||||
FROM message msg
|
||||
JOIN member m ON msg.sender_id = m.id
|
||||
${clauseWithSystem}
|
||||
GROUP BY year
|
||||
ORDER BY year
|
||||
`
|
||||
)
|
||||
.all(...params) as Array<{ year: number; messageCount: number }>
|
||||
|
||||
return rows.map((r) => ({
|
||||
year: r.year,
|
||||
messageCount: r.messageCount,
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息类型分布
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@ export {
|
||||
getDailyActivity,
|
||||
getWeekdayActivity,
|
||||
getMonthlyActivity,
|
||||
getYearlyActivity,
|
||||
getMessageTypeDistribution,
|
||||
getTimeRange,
|
||||
getMemberNameHistory,
|
||||
|
||||
Reference in New Issue
Block a user