MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / getSessionOverview

Function getSessionOverview

packages/core/src/query/session-queries.ts:148–175  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

146 * 查询会话基础统计(消息数、成员数、时间范围)
147 */
148export function getSessionOverview(db: DatabaseAdapter): SessionOverview {
149 const msgRow = db
150 .prepare(
151 `SELECT COUNT(*) as count
152 FROM message msg
153 JOIN member m ON msg.sender_id = m.id
154 WHERE COALESCE(m.account_name, '') != '系统消息'`
155 )
156 .get() as { count: number }
157
158 const memberRow = db
159 .prepare(
160 `SELECT COUNT(*) as count
161 FROM member
162 WHERE COALESCE(account_name, '') != '系统消息'`
163 )
164 .get() as { count: number }
165
166 const firstTs = (db.prepare('SELECT MIN(ts) as v FROM message').get() as { v: number | null })?.v ?? null
167 const lastTs = (db.prepare('SELECT MAX(ts) as v FROM message').get() as { v: number | null })?.v ?? null
168
169 return {
170 totalMessages: msgRow.count,
171 totalMembers: memberRow.count,
172 firstMessageTs: firstTs,
173 lastMessageTs: lastTs,
174 }
175}
176
177/**
178 * 获取数据库中的表结构(Schema)

Callers 8

handlerFunction · 0.90
handlerFunction · 0.90
registerResourcesFunction · 0.90
resolveOverviewFunction · 0.90
cli.tsFile · 0.90
getSessionInfoFunction · 0.85
getChatOverviewFunction · 0.85

Calls 2

getMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected