fix: comments

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-16 09:04:10 +01:00
parent 6403c77e06
commit add80097d4
3 changed files with 15 additions and 12 deletions

View File

@@ -139,8 +139,8 @@ export async function up() {
const firstEventDateJson = await firstEventDateResponse.json<{ const firstEventDateJson = await firstEventDateResponse.json<{
created_at: string; created_at: string;
}>(); }>();
const firstEventDate = new Date(firstEventDateJson[0]?.created_at ?? ''); if (firstEventDateJson[0]?.created_at) {
if (firstEventDate) { const firstEventDate = new Date(firstEventDateJson[0]?.created_at);
// Step 2: Copy data from old tables to new tables (partitioned by month for efficiency) // 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 // Set endDate to first of next month to ensure we capture all data in the current month
const endDate = new Date(); const endDate = new Date();
@@ -174,8 +174,10 @@ export async function up() {
created_at: string; created_at: string;
}>(); }>();
const firstSessionDate = new Date(firstSessionDateJson[0]?.created_at ?? ''); if (firstSessionDateJson[0]?.created_at) {
if (firstSessionDate) { 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 // Set endDate to first of next month to ensure we capture all data in the current month
const endDate = new Date(); const endDate = new Date();
endDate.setMonth(endDate.getMonth() + 1); endDate.setMonth(endDate.getMonth() + 1);
@@ -249,11 +251,11 @@ export async function up() {
if (isClustered && sessionTables[1] && eventTables[1]) { if (isClustered && sessionTables[1] && eventTables[1]) {
sqls.push( sqls.push(
// Drop temporary DISTRIBUTED tables (will be recreated) // Drop temporary DISTRIBUTED tables (will be recreated)
'DROP TABLE IF EXISTS events_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}"', `DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER '{cluster}'`,
// Rename new tables to correct names // Rename new tables to correct names
'RENAME TABLE events_new_20251123_replicated TO events_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}"', `RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER '{cluster}'`,
// Create new distributed tables // Create new distributed tables
eventTables[1].replaceAll('events_new_20251123', 'events'), // creates a new distributed table eventTables[1].replaceAll('events_new_20251123', 'events'), // creates a new distributed table
sessionTables[1].replaceAll('sessions_new_20251123', 'sessions'), // creates a new distributed table sessionTables[1].replaceAll('sessions_new_20251123', 'sessions'), // creates a new distributed table

View File

@@ -196,8 +196,9 @@ export async function getSessionList({
if (cursor) { if (cursor) {
const cAt = sqlstring.escape(cursor.createdAt); const cAt = sqlstring.escape(cursor.createdAt);
// TODO: remove id from cursor
const cId = sqlstring.escape(cursor.id); 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.where.cursorWindow = `created_at >= toDateTime64(${cAt}, 3) - INTERVAL ${dateIntervalInDays} DAY`;
sb.orderBy.created_at = 'created_at DESC'; sb.orderBy.created_at = 'created_at DESC';
} else { } else {

View File

@@ -89,7 +89,7 @@ services:
max-file: "3" max-file: "3"
op-api: op-api:
image: lindesvard/openpanel-api:2.0.0 image: lindesvard/openpanel-api:latest
restart: always restart: always
command: > command: >
sh -c " sh -c "
@@ -119,7 +119,7 @@ services:
max-file: "3" max-file: "3"
op-dashboard: op-dashboard:
image: lindesvard/openpanel-dashboard:2.0.0 image: lindesvard/openpanel-dashboard:latest
restart: always restart: always
depends_on: depends_on:
op-api: op-api:
@@ -139,7 +139,7 @@ services:
max-file: "3" max-file: "3"
op-worker: op-worker:
image: lindesvard/openpanel-worker:2.0.0 image: lindesvard/openpanel-worker:latest
restart: always restart: always
depends_on: depends_on:
op-api: op-api: