()
| 89 | |
| 90 | async function createOldSessions() { |
| 91 | async function getFirstEventAt() { |
| 92 | const defaultDate = new Date('2024-03-01'); |
| 93 | try { |
| 94 | const res = await chMigrationClient.query({ |
| 95 | query: `SELECT min(created_at) as created_at, count() as count FROM ${TABLE_NAMES.events}`, |
| 96 | format: 'JSONEachRow', |
| 97 | }); |
| 98 | const json = await res.json<{ created_at: string; count: string }>(); |
| 99 | const row = json[0]; |
| 100 | if (!row || row.count === '0') { |
| 101 | return null; |
| 102 | } |
| 103 | if (row.created_at.startsWith('1970')) { |
| 104 | return null; |
| 105 | } |
| 106 | return new Date(row.created_at); |
| 107 | } catch (e) { |
| 108 | return defaultDate; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | let startDate = await getFirstEventAt(); |
| 113 |
no test coverage detected