(
timeFilter?: { startTs?: number; endTs?: number },
memberId?: number
)
| 17 | import { segment, batchSegmentWithFrequency, batchSegmentChineseWithStats, collectPosTagStats } from './segmenter' |
| 18 | |
| 19 | function 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 | * 从数据库计算词频统计 |
no outgoing calls
no test coverage detected