parametr forceupdate jidla
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful

This commit is contained in:
batmanisko 2025-07-29 11:33:31 +02:00
parent cf8be8c64f
commit fa4f9903cb
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View File

@ -156,7 +156,7 @@ router.get("/refresh", async (req: Request, res: Response) => {
const firstDay = getFirstWorkDayOfWeek(getToday());
const results: Record<string, any> = {};
for (const rest of restaurants) {
results[rest] = await getRestaurantMenu(rest, firstDay);
results[rest] = await getRestaurantMenu(rest, firstDay, true);
}
res.status(200).json({ ok: true, refreshed: results });
} catch (e: any) {

View File

@ -84,7 +84,7 @@ async function getMenu(date: Date): Promise<WeekMenu | undefined> {
* @param date datum, ke kterému získat menu
* @param mock příznak, zda chceme pouze mock data
*/
export async function getRestaurantMenu(restaurant: Restaurant, date?: Date): Promise<RestaurantDayMenu> {
export async function getRestaurantMenu(restaurant: Restaurant, date?: Date, forceRefresh = false): Promise<RestaurantDayMenu> {
const usedDate = date ?? getToday();
const dayOfWeekIndex = getDayOfWeekIndex(usedDate);
const now = new Date().getTime();
@ -112,7 +112,7 @@ export async function getRestaurantMenu(restaurant: Restaurant, date?: Date): Pr
};
}
}
if (!weekMenu[dayOfWeekIndex][restaurant]?.food?.length) {
if (forceRefresh || !weekMenu[dayOfWeekIndex][restaurant]?.food?.length) {
const firstDay = getFirstWorkDayOfWeek(usedDate);
const mock = process.env.MOCK_DATA === 'true';
switch (restaurant) {