parametr forceupdate jidla
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
This commit is contained in:
parent
cf8be8c64f
commit
fa4f9903cb
@ -156,7 +156,7 @@ router.get("/refresh", async (req: Request, res: Response) => {
|
|||||||
const firstDay = getFirstWorkDayOfWeek(getToday());
|
const firstDay = getFirstWorkDayOfWeek(getToday());
|
||||||
const results: Record<string, any> = {};
|
const results: Record<string, any> = {};
|
||||||
for (const rest of restaurants) {
|
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 });
|
res.status(200).json({ ok: true, refreshed: results });
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -84,7 +84,7 @@ async function getMenu(date: Date): Promise<WeekMenu | undefined> {
|
|||||||
* @param date datum, ke kterému získat menu
|
* @param date datum, ke kterému získat menu
|
||||||
* @param mock příznak, zda chceme pouze mock data
|
* @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 usedDate = date ?? getToday();
|
||||||
const dayOfWeekIndex = getDayOfWeekIndex(usedDate);
|
const dayOfWeekIndex = getDayOfWeekIndex(usedDate);
|
||||||
const now = new Date().getTime();
|
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 firstDay = getFirstWorkDayOfWeek(usedDate);
|
||||||
const mock = process.env.MOCK_DATA === 'true';
|
const mock = process.env.MOCK_DATA === 'true';
|
||||||
switch (restaurant) {
|
switch (restaurant) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user