diff --git a/packages/db/code-migrations/8-order-keys.ts b/packages/db/code-migrations/8-order-keys.ts index 640edd8e..cb2b5bf2 100644 --- a/packages/db/code-migrations/8-order-keys.ts +++ b/packages/db/code-migrations/8-order-keys.ts @@ -139,8 +139,8 @@ export async function up() { const firstEventDateJson = await firstEventDateResponse.json<{ created_at: string; }>(); - const firstEventDate = new Date(firstEventDateJson[0]?.created_at ?? ''); - if (firstEventDate) { + if (firstEventDateJson[0]?.created_at) { + const firstEventDate = new Date(firstEventDateJson[0]?.created_at); // Step 2: Copy data from old tables to new tables (partitioned by month for efficiency) // Set endDate to first of next month to ensure we capture all data in the current month const endDate = new Date(); @@ -174,8 +174,10 @@ export async function up() { created_at: string; }>(); - const firstSessionDate = new Date(firstSessionDateJson[0]?.created_at ?? ''); - if (firstSessionDate) { + if (firstSessionDateJson[0]?.created_at) { + const firstSessionDate = new Date( + firstSessionDateJson[0]?.created_at ?? '', + ); // Set endDate to first of next month to ensure we capture all data in the current month const endDate = new Date(); endDate.setMonth(endDate.getMonth() + 1); @@ -249,11 +251,11 @@ export async function up() { if (isClustered && sessionTables[1] && eventTables[1]) { sqls.push( // Drop temporary DISTRIBUTED tables (will be recreated) - 'DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER "{cluster}"', - 'DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER "{cluster}"', + `DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER '{cluster}'`, + `DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER '{cluster}'`, // Rename new tables to correct names - 'RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER "{cluster}"', - 'RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER "{cluster}"', + `RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER '{cluster}'`, + `RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER '{cluster}'`, // Create new distributed tables eventTables[1].replaceAll('events_new_20251123', 'events'), // creates a new distributed table sessionTables[1].replaceAll('sessions_new_20251123', 'sessions'), // creates a new distributed table diff --git a/packages/db/src/services/session.service.ts b/packages/db/src/services/session.service.ts index 0f8eb6f4..0d39460a 100644 --- a/packages/db/src/services/session.service.ts +++ b/packages/db/src/services/session.service.ts @@ -196,8 +196,9 @@ export async function getSessionList({ if (cursor) { const cAt = sqlstring.escape(cursor.createdAt); + // TODO: remove id from cursor const cId = sqlstring.escape(cursor.id); - sb.where.cursor = `(created_at < toDateTime64(${cAt}, 3) OR (created_at = toDateTime64(${cAt}, 3) AND id < ${cId}))`; + sb.where.cursor = `created_at < toDateTime64(${cAt}, 3)`; sb.where.cursorWindow = `created_at >= toDateTime64(${cAt}, 3) - INTERVAL ${dateIntervalInDays} DAY`; sb.orderBy.created_at = 'created_at DESC'; } else { diff --git a/self-hosting/docker-compose.template.yml b/self-hosting/docker-compose.template.yml index 205d5dc4..12d9b828 100644 --- a/self-hosting/docker-compose.template.yml +++ b/self-hosting/docker-compose.template.yml @@ -89,7 +89,7 @@ services: max-file: "3" op-api: - image: lindesvard/openpanel-api:2.0.0 + image: lindesvard/openpanel-api:latest restart: always command: > sh -c " @@ -119,7 +119,7 @@ services: max-file: "3" op-dashboard: - image: lindesvard/openpanel-dashboard:2.0.0 + image: lindesvard/openpanel-dashboard:latest restart: always depends_on: op-api: @@ -139,7 +139,7 @@ services: max-file: "3" op-worker: - image: lindesvard/openpanel-worker:2.0.0 + image: lindesvard/openpanel-worker:latest restart: always depends_on: op-api: