MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getFirstEventAt

Function getFirstEventAt

packages/db/code-migrations/4-add-sessions.ts:91–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90async 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

Callers 1

createOldSessionsFunction · 0.85

Calls 1

queryMethod · 0.80

Tested by

no test coverage detected