Skip to content

Commit d275bb0

Browse files
committed
dont count the initial sync as new products
1 parent b06fae2 commit d275bb0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/routes/(info)/lttstore/[store]/+page.server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { error } from "@sveltejs/kit";
22
import type { PageServerLoad } from "./$types";
33
import { dev } from "$app/environment";
4-
import { type ProductsTableRow, storeIdFromName } from "$lib/lttstore/lttstore_types.ts";
4+
import { type ProductsTableRow, Store, storeIdFromName } from "$lib/lttstore/lttstore_types.ts";
55
import { createTables } from "../createTables.ts";
66
import { retryD1 } from "$lib/utils.ts";
77

@@ -37,16 +37,18 @@ export const load = (async ({platform, params}) => {
3737
.then(r => r.results)
3838
);
3939

40+
const sixDaysAgo = Date.now() - (6 * 24 * 60 * 60e3);
41+
4042
const recentRestocks = retryD1(() =>
4143
db.prepare("select * from products where store = ? and lastRestock > ? order by lastRestock DESC limit 30")
42-
.bind(store, Date.now() - (6 * 24 * 60 * 60e3))
44+
.bind(store, sixDaysAgo)
4345
.all<ProductsTableRow>()
4446
.then(r => r.results)
4547
);
4648

4749
let newProducts = await retryD1(() =>
4850
db.prepare("select * from products where store = ? and firstSeen > ? order by firstSeen DESC limit 50")
49-
.bind(store, Date.now() - (6 * 24 * 60 * 60e3))
51+
.bind(store, store === Store.US ? sixDaysAgo : Math.max(sixDaysAgo, 1781787820145))
5052
.all<ProductsTableRow>()
5153
.then(r => r.results)
5254
);

0 commit comments

Comments
 (0)