fix: dočasné skrytí podniku Šenk Šeříková
CI / Generate TypeScript types (push) Successful in 11s
CI / Server unit tests (push) Successful in 27s
CI / Build server (push) Successful in 29s
CI / Build client (push) Successful in 40s
CI / Playwright E2E tests (push) Failing after 2m44s
CI / Build and push Docker image (push) Skipped
CI / Notify (push) Successful in 2s

This commit is contained in:
mates committed 2026-10-09 14:45:00 +02:00
1 parent 9fee4a1538
commit 49508dacd0
5 files changed
+45 -24

No files matched your search

+28 -7
View File
@@ -9,6 +9,24 @@ import { ClientData, DepartureTime, LunchChoice, LunchChoices, MealSlot, PizzaDa
const storage = getStorage();
const MENU_PREFIX = 'menu';
/**
* Dočasně uzavřené podniky – nezobrazují se na hlavní stránce, nelze je zvolit
* a neprovádí se pro ně načítání menu z jejich webu.
*/
export const DISABLED_RESTAURANTS: readonly Restaurant[] = [
Restaurant.SENKSERIKOVA, // dočasně uzavřen
];
/** Vrátí true, pokud je podnik dočasně vyřazen z nabídky. */
export function isRestaurantDisabled(restaurant: Restaurant | LunchChoice): boolean {
return DISABLED_RESTAURANTS.includes(restaurant as Restaurant);
}
/** Vrátí podniky s menu, které nejsou dočasně vyřazeny. */
export function getActiveRestaurants(): Restaurant[] {
return (Object.values(Restaurant) as Restaurant[]).filter(r => !isRestaurantDisabled(r));
}
function getDataKey(date: Date, slot?: MealSlot): string {
const base = formatDate(date);
return slot === MealSlot.EXTRA ? `${base}_extra` : base;
@@ -55,13 +73,12 @@ export async function getData(date?: Date, slot?: MealSlot): Promise<ClientData>
if (slot === MealSlot.EXTRA) {
clientData.stores = await getStores();
} else {
clientData.menus = {
SLADOVNICKA: await getRestaurantMenu('SLADOVNICKA', date),
// UMOTLIKU: await getRestaurantMenu('UMOTLIKU', date),
TECHTOWER: await getRestaurantMenu('TECHTOWER', date),
ZASTAVKAUMICHALA: await getRestaurantMenu('ZASTAVKAUMICHALA', date),
SENKSERIKOVA: await getRestaurantMenu('SENKSERIKOVA', date),
// Dočasně vyřazené podniky se do odpovědi vůbec nezahrnují (klient je pak nezobrazí)
const menus: RestaurantDayMenuMap = {};
for (const restaurant of getActiveRestaurants()) {
menus[restaurant] = await getRestaurantMenu(restaurant, date);
}
clientData.menus = menus;
// Očistí volby jídel odkazující na indexy, které v aktuálním menu již neexistují.
// Pokud se v odpovědi něco změnilo, promítne očistu i do uložených dat (self-heal).
if (pruneStaleFoodChoices(clientData.choices, clientData.menus)) {
@@ -236,7 +253,8 @@ export async function getRestaurantMenu(restaurant: Restaurant, date?: Date, for
const usedDate = date ?? getToday();
const dayOfWeekIndex = getDayOfWeekIndex(usedDate);
const now = new Date().getTime();
if (getIsWeekend(usedDate)) {
// O víkendu a u dočasně vyřazených podniků menu vůbec nenačítáme
if (getIsWeekend(usedDate) || isRestaurantDisabled(restaurant)) {
return {
lastUpdate: now,
closed: true,
@@ -468,6 +486,9 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lu
await initIfNeeded(usedDate, slot);
let data = await getClientData(usedDate, slot);
validateTrusted(data, login, trusted);
if (isRestaurantDisabled(locationKey)) {
throw new Error(`Podnik ${locationKey} je dočasně uzavřen`);
}
await validateFoodIndex(locationKey, foodIndex, date);
if (!slot || slot === MealSlot.OBED) {