fix: oprava varování "Data jsou z minulého týdne"
CI / Generate TypeScript types (push) Successful in 17s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 32s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m47s
CI / Build and push Docker image (push) Successful in 1m9s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 17s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 32s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m47s
CI / Build and push Docker image (push) Successful in 1m9s
CI / Notify (push) Successful in 2s
This commit is contained in:
@@ -259,8 +259,10 @@ export async function getRestaurantMenu(restaurant: Restaurant, date?: Date, for
|
||||
const lastFetchExpired = !existingMenu?.lastUpdate ||
|
||||
existingMenu.lastUpdate === now || // freshly initialized, never fetched
|
||||
(now - existingMenu.lastUpdate) > MENU_REFETCH_TTL_MS;
|
||||
const shouldFetch = forceRefresh ||
|
||||
(!existingMenu?.food?.length && !existingMenu?.closed && lastFetchExpired);
|
||||
// Data označená jako "z minulého týdne" se musí zkoušet načíst znovu, jinak by u nich
|
||||
// varování zůstalo viset celý týden i poté, co podnik nabídku na svém webu aktualizuje.
|
||||
const needsData = existingMenu?.isStale || (!existingMenu?.food?.length && !existingMenu?.closed);
|
||||
const shouldFetch = forceRefresh || (needsData && lastFetchExpired);
|
||||
if (shouldFetch) {
|
||||
const firstDay = getFirstWorkDayOfWeek(usedDate);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user