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

Function getSessionsByTimeRange

packages/core/src/query/session-queries.ts:433–451  ·  view source on GitHub ↗
(db: DatabaseAdapter, startTs: number, endTs: number)

Source from the content-addressed store, hash-verified

431 * Query chat sessions within a time range.
432 */
433export function getSessionsByTimeRange(db: DatabaseAdapter, startTs: number, endTs: number): ChatSessionItem[] {
434 if (!hasTable(db, 'segment')) return []
435 try {
436 return db
437 .prepare(
438 `SELECT
439 id, start_ts as startTs, end_ts as endTs,
440 message_count as messageCount, summary,
441 (SELECT mc.message_id FROM message_context mc
442 WHERE mc.segment_id = cs.id ORDER BY mc.message_id LIMIT 1) as firstMessageId
443 FROM segment cs
444 WHERE start_ts >= ? AND start_ts <= ?
445 ORDER BY start_ts DESC`
446 )
447 .all(startTs, endTs) as unknown as ChatSessionItem[]
448 } catch {
449 return []
450 }
451}
452
453/**
454 * Get the most recent N chat sessions.

Callers

nothing calls this directly

Calls 3

hasTableFunction · 0.90
allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected