File tree Expand file tree Collapse file tree
src/routes/(info)/lttstore/[store] Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { error } from "@sveltejs/kit" ;
22import type { PageServerLoad } from "./$types" ;
33import { 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" ;
55import { createTables } from "../createTables.ts" ;
66import { 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 ) ;
You can’t perform that action at this time.
0 commit comments