fix: akualizace detekce polévek pro TechTower
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 27s
CI / Build server (push) Successful in 29s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m22s
CI / Build and push Docker image (push) Successful in 46s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 27s
CI / Build server (push) Successful in 29s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m22s
CI / Build and push Docker image (push) Successful in 46s
CI / Notify (push) Successful in 2s
This commit is contained in:
1 parent
61fd1cfe32
commit
3c08f71f63
1 file changed
+18
-17
+18
-17
@@ -37,6 +37,7 @@ const SOUP_NAMES = [
|
||||
'hrášková s ',
|
||||
'hrachová s ',
|
||||
'bramborový krém',
|
||||
'kaldoun',
|
||||
];
|
||||
const DAYS_IN_WEEK = ['pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota', 'neděle'];
|
||||
|
||||
@@ -82,14 +83,14 @@ export const parseAllergens = (name: string): { cleanName: string, allergens: nu
|
||||
// Regex pro nalezení čísel na konci řetězce oddělených čárkami a případnými mezerami
|
||||
const regex = /\s+(\d+(?:\s*,\s*\d+)*)\s*$/;
|
||||
const match = regex.exec(name);
|
||||
|
||||
|
||||
if (match) {
|
||||
const allergenString = match[1];
|
||||
const allergens = allergenString.split(',').map(num => Number.parseInt(num.trim(), 10)).filter(num => !Number.isNaN(num));
|
||||
const cleanName = name.replace(regex, '').trim();
|
||||
return { cleanName, allergens };
|
||||
}
|
||||
|
||||
|
||||
return { cleanName: name, allergens: [] };
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
||||
// Zjistíme, které dny jsou k dispozici z tab elementů
|
||||
const tabElements = $('#daily-menu-tab-list').children('button[id^="daily-menu-tab-"]');
|
||||
const availableDays: { [dayIndex: number]: number } = {}; // mapování dayIndex -> contentIndex
|
||||
|
||||
|
||||
tabElements.each((contentIndex, tabElement) => {
|
||||
const dayText = $(tabElement).find('.daily-menu-tab__day').text().toLowerCase();
|
||||
const dayIndex = DAYS_IN_WEEK.indexOf(dayText);
|
||||
@@ -131,42 +132,42 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
||||
});
|
||||
|
||||
const menuContentElements = $('#daily-menu-content-list').children('.daily-menu-content__content').not('.daily-menu-content__content--static');
|
||||
|
||||
|
||||
const result: Food[][] = [];
|
||||
|
||||
|
||||
// Inicializujeme všechny pracovní dny (0-4) prázdnými poli
|
||||
for (let dayIndex = 0; dayIndex < 5; dayIndex++) {
|
||||
result[dayIndex] = [];
|
||||
}
|
||||
|
||||
|
||||
// Projdeme pouze dostupné dny
|
||||
for (const [dayIndex, contentIndex] of Object.entries(availableDays)) {
|
||||
const dayIndexNum = Number.parseInt(dayIndex);
|
||||
const contentIndexNum = contentIndex;
|
||||
|
||||
|
||||
if (contentIndexNum >= menuContentElements.length) {
|
||||
continue; // Přeskočíme, pokud content element neexistuje
|
||||
}
|
||||
|
||||
|
||||
const contentElement = $(menuContentElements[contentIndexNum]);
|
||||
const itemElement = contentElement.find('.daily-menu-content__item');
|
||||
const table = itemElement.find('table.daily-menu-content__table tbody');
|
||||
const rows = table.children('tr');
|
||||
|
||||
|
||||
const currentDayFood: Food[] = [];
|
||||
|
||||
|
||||
// Projdeme všechny řádky - první je polévka, zbytek jsou hlavní jídla
|
||||
rows.each((i, row) => {
|
||||
const cells = $(row).children('td');
|
||||
if (cells.length !== 3) {
|
||||
return; // Přeskočíme řádky s nesprávnou strukturou
|
||||
}
|
||||
|
||||
|
||||
const amount = sanitizeText($(cells.get(0)).text());
|
||||
const nameRaw = sanitizeText($(cells.get(1)).text());
|
||||
const price = sanitizeText($(cells.get(2)).text().replace(' ', '\xA0'));
|
||||
const parsed = parseAllergens(nameRaw);
|
||||
|
||||
|
||||
// Přeskočíme prázdné řádky
|
||||
if (parsed.cleanName.trim().length > 0) {
|
||||
currentDayFood.push({
|
||||
@@ -181,7 +182,7 @@ export const getMenuSladovnicka = async (firstDayOfWeek: Date, mock: boolean = f
|
||||
|
||||
result[dayIndexNum] = currentDayFood;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -539,7 +540,7 @@ export const getMenuZastavkaUmichala = async (firstDayOfWeek: Date, mock: boolea
|
||||
}
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0,0,0,0);
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const headers = {
|
||||
"Cookie": "_nss=1; PHPSESSID=9e37de17e0326b0942613d6e67a30e69",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36",
|
||||
@@ -548,7 +549,7 @@ export const getMenuZastavkaUmichala = async (firstDayOfWeek: Date, mock: boolea
|
||||
for (let dayIndex = 0; dayIndex < 5; dayIndex++) {
|
||||
const currentDate = new Date(firstDayOfWeek);
|
||||
currentDate.setDate(firstDayOfWeek.getDate() + dayIndex);
|
||||
currentDate.setHours(0,0,0,0);
|
||||
currentDate.setHours(0, 0, 0, 0);
|
||||
if (currentDate < today || (currentDate.getTime() === today.getTime() && new Date().getHours() >= 14)) {
|
||||
result[dayIndex] = [{
|
||||
amount: undefined,
|
||||
@@ -600,11 +601,11 @@ export const getMenuSenkSerikova = async (firstDayOfWeek: Date, mock: boolean =
|
||||
const $ = load(html);
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0,0,0,0);
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const currentDate = new Date(firstDayOfWeek);
|
||||
const result: Food[][] = [];
|
||||
let dayIndex = 0;
|
||||
currentDate.setHours(0,0,0,0);
|
||||
currentDate.setHours(0, 0, 0, 0);
|
||||
while (currentDate < today) {
|
||||
result[dayIndex] = [{
|
||||
amount: undefined,
|
||||
|
||||
Reference in new issue
Block a user