Skip to content

Commit add8009

Browse files
committed
fix: comments
1 parent 6403c77 commit add8009

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

packages/db/code-migrations/8-order-keys.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export async function up() {
139139
const firstEventDateJson = await firstEventDateResponse.json<{
140140
created_at: string;
141141
}>();
142-
const firstEventDate = new Date(firstEventDateJson[0]?.created_at ?? '');
143-
if (firstEventDate) {
142+
if (firstEventDateJson[0]?.created_at) {
143+
const firstEventDate = new Date(firstEventDateJson[0]?.created_at);
144144
// Step 2: Copy data from old tables to new tables (partitioned by month for efficiency)
145145
// Set endDate to first of next month to ensure we capture all data in the current month
146146
const endDate = new Date();
@@ -174,8 +174,10 @@ export async function up() {
174174
created_at: string;
175175
}>();
176176

177-
const firstSessionDate = new Date(firstSessionDateJson[0]?.created_at ?? '');
178-
if (firstSessionDate) {
177+
if (firstSessionDateJson[0]?.created_at) {
178+
const firstSessionDate = new Date(
179+
firstSessionDateJson[0]?.created_at ?? '',
180+
);
179181
// Set endDate to first of next month to ensure we capture all data in the current month
180182
const endDate = new Date();
181183
endDate.setMonth(endDate.getMonth() + 1);
@@ -249,11 +251,11 @@ export async function up() {
249251
if (isClustered && sessionTables[1] && eventTables[1]) {
250252
sqls.push(
251253
// Drop temporary DISTRIBUTED tables (will be recreated)
252-
'DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER "{cluster}"',
253-
'DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER "{cluster}"',
254+
`DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER '{cluster}'`,
255+
`DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER '{cluster}'`,
254256
// Rename new tables to correct names
255-
'RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER "{cluster}"',
256-
'RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER "{cluster}"',
257+
`RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER '{cluster}'`,
258+
`RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER '{cluster}'`,
257259
// Create new distributed tables
258260
eventTables[1].replaceAll('events_new_20251123', 'events'), // creates a new distributed table
259261
sessionTables[1].replaceAll('sessions_new_20251123', 'sessions'), // creates a new distributed table

packages/db/src/services/session.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@ export async function getSessionList({
196196

197197
if (cursor) {
198198
const cAt = sqlstring.escape(cursor.createdAt);
199+
// TODO: remove id from cursor
199200
const cId = sqlstring.escape(cursor.id);
200-
sb.where.cursor = `(created_at < toDateTime64(${cAt}, 3) OR (created_at = toDateTime64(${cAt}, 3) AND id < ${cId}))`;
201+
sb.where.cursor = `created_at < toDateTime64(${cAt}, 3)`;
201202
sb.where.cursorWindow = `created_at >= toDateTime64(${cAt}, 3) - INTERVAL ${dateIntervalInDays} DAY`;
202203
sb.orderBy.created_at = 'created_at DESC';
203204
} else {

self-hosting/docker-compose.template.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ services:
8989
max-file: "3"
9090

9191
op-api:
92-
image: lindesvard/openpanel-api:2.0.0
92+
image: lindesvard/openpanel-api:latest
9393
restart: always
9494
command: >
9595
sh -c "
@@ -119,7 +119,7 @@ services:
119119
max-file: "3"
120120

121121
op-dashboard:
122-
image: lindesvard/openpanel-dashboard:2.0.0
122+
image: lindesvard/openpanel-dashboard:latest
123123
restart: always
124124
depends_on:
125125
op-api:
@@ -139,7 +139,7 @@ services:
139139
max-file: "3"
140140

141141
op-worker:
142-
image: lindesvard/openpanel-worker:2.0.0
142+
image: lindesvard/openpanel-worker:latest
143143
restart: always
144144
depends_on:
145145
op-api:

0 commit comments

Comments
 (0)