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

Function seedChatDb

tests/chart-runtime/real-llm-chart-flow.e2e.test.ts:36–75  ·  view source on GitHub ↗
(db: ReturnType<typeof openBetterSqliteDatabase>)

Source from the content-addressed store, hash-verified

34}
35
36function seedChatDb(db: ReturnType<typeof openBetterSqliteDatabase>): void {
37 db.exec(CHAT_DB_SCHEMA)
38 db.prepare(
39 `INSERT INTO meta (name, platform, type, imported_at, group_id, owner_id)
40 VALUES ('Chart E2E Group', 'wechat', 'group', ?, 'g1', 'u_alice')`
41 ).run(unixTs('2026-06-03T00:00:00Z'))
42
43 const insertMember = db.prepare(
44 `INSERT INTO member (platform_id, account_name, group_nickname)
45 VALUES (?, ?, ?)`
46 )
47 insertMember.run('u_alice', 'Alice Account', 'Alice')
48 insertMember.run('u_bob', 'Bob Account', 'Bob')
49 insertMember.run('u_cara', 'Cara Account', 'Cara')
50
51 const memberRows = db.prepare('SELECT id, group_nickname FROM member').all() as Array<{
52 id: number
53 group_nickname: string
54 }>
55 const memberId = new Map(memberRows.map((row) => [row.group_nickname, row.id]))
56 const insertMessage = db.prepare(
57 `INSERT INTO message (sender_id, sender_account_name, sender_group_nickname, ts, type, content, platform_message_id)
58 VALUES (?, ?, ?, ?, ?, ?, ?)`
59 )
60 const add = (name: 'Alice' | 'Bob' | 'Cara', ts: string, type: number, content: string) => {
61 const id = memberId.get(name)
62 assert.ok(id, `missing member id for ${name}`)
63 insertMessage.run(id, `${name} Account`, name, unixTs(ts), type, content, `${name}-${ts}`)
64 }
65
66 add('Alice', '2026-06-01T09:00:00Z', 0, 'morning hello')
67 add('Alice', '2026-06-01T10:00:00Z', 0, 'standup note')
68 add('Alice', '2026-06-02T09:00:00Z', 1, '[图片]')
69 add('Alice', '2026-06-02T10:00:00Z', 0, 'follow up')
70 add('Bob', '2026-06-01T09:00:00Z', 0, 'first reply')
71 add('Bob', '2026-06-02T10:00:00Z', 0, 'second reply')
72 add('Bob', '2026-06-02T11:00:00Z', 0, 'third reply')
73 add('Cara', '2026-06-01T09:00:00Z', 0, 'other member')
74 add('Cara', '2026-06-03T12:00:00Z', 0, 'outside selected members')
75}
76
77function convertJsonSchemaToParameters(schema: ToolDefinition['inputSchema']) {
78 const properties: Record<string, unknown> = {}

Callers 1

Calls 6

unixTsFunction · 0.70
addFunction · 0.70
execMethod · 0.65
runMethod · 0.65
prepareMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected