Skip to content

Commit 22e7771

Browse files
committed
fix threshold
1 parent 577b462 commit 22e7771

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

view/src/routes/visits/+server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { ServerLoad } from '@sveltejs/kit';
2-
import { and, eq, lte } from 'drizzle-orm';
2+
import { and, eq, gte } from 'drizzle-orm';
33
import { drizzle } from 'drizzle-orm/d1';
44
import { visitsTable } from '~/db/schema';
55

66
const MS_PER_DAY = 24 * 60 * 60 * 1000;
77
export const GET: ServerLoad = async ({ params, platform }) => {
88
const duration = Number.parseInt(params.duration ?? '') || 3;
9-
const threshold = new Date(new Date().getTime() + duration * MS_PER_DAY);
9+
const threshold = new Date(new Date().getTime() - duration * MS_PER_DAY);
1010
const kind = params.kind ?? 'all';
1111

1212
if (!platform) return new Response('platform not found');
@@ -17,7 +17,7 @@ export const GET: ServerLoad = async ({ params, platform }) => {
1717
.where(
1818
and(
1919
eq(visitsTable.kind, kind !== 'all' ? kind : visitsTable.kind),
20-
lte(visitsTable.at, threshold)
20+
gte(visitsTable.at, threshold)
2121
)
2222
)
2323
.all();

0 commit comments

Comments
 (0)