MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / buildMessageQuery

Function buildMessageQuery

packages/node-runtime/src/nlp/word-frequency.ts:19–48  ·  view source on GitHub ↗
(
  timeFilter?: { startTs?: number; endTs?: number },
  memberId?: number
)

Source from the content-addressed store, hash-verified

17import { segment, batchSegmentWithFrequency, batchSegmentChineseWithStats, collectPosTagStats } from './segmenter'
18
19function buildMessageQuery(
20 timeFilter?: { startTs?: number; endTs?: number },
21 memberId?: number
22): { clause: string; params: unknown[] } {
23 const conditions: string[] = []
24 const params: unknown[] = []
25
26 if (timeFilter?.startTs !== undefined) {
27 conditions.push('msg.ts >= ?')
28 params.push(timeFilter.startTs)
29 }
30 if (timeFilter?.endTs !== undefined) {
31 conditions.push('msg.ts <= ?')
32 params.push(timeFilter.endTs)
33 }
34 if (memberId !== undefined && memberId !== null) {
35 conditions.push('msg.sender_id = ?')
36 params.push(memberId)
37 }
38
39 conditions.push("COALESCE(m.account_name, '') != '系统消息'")
40 conditions.push('msg.type = 0')
41 conditions.push('msg.content IS NOT NULL')
42 conditions.push("TRIM(msg.content) != ''")
43
44 return {
45 clause: ` WHERE ${conditions.join(' AND ')}`,
46 params,
47 }
48}
49
50/**
51 * 从数据库计算词频统计

Callers 1

computeWordFrequencyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected