Skip to content

Commit 5ab42af

Browse files
committed
fix error
1 parent 8e1de74 commit 5ab42af

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

src/monitor.js

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -344,64 +344,7 @@ async function getChernivtsiData(browser) {
344344
}
345345
}
346346
// --- ТРАНСФОРМАЦІЇ ---
347-
function transformToSvitloFormat(dtekRaw) {
348-
await sleep(5000);
349-
350-
const schedule = await page.evaluate(() => {
351-
const dateEl = document.querySelector('#gsv_t b');
352-
if (!dateEl) return null;
353-
354-
// Format: 30.01.2026
355-
const dateParts = dateEl.innerText.trim().split('.');
356-
if (dateParts.length !== 3) return null;
357-
const dateStr = `${dateParts[2]}-${dateParts[1]}-${dateParts[0]}`; // 2026-01-30
358-
359-
const rows = document.querySelectorAll('#gsv .scrollable div[id^="inf"]');
360-
const map = {};
361-
362-
rows.forEach(row => {
363-
const queueId = row.getAttribute('data-id');
364-
if (!queueId) return;
365347

366-
// Checking for the active container inside the row
367-
const cellContainer = row.querySelector('o.active');
368-
if (!cellContainer) return;
369-
370-
const cells = Array.from(cellContainer.children);
371-
if (cells.length < 48) return; // Expecting at least 48 slots
372-
373-
const dailySchedule = {};
374-
cells.forEach((cell, i) => {
375-
if (i >= 48) return;
376-
const hour = Math.floor(i / 2);
377-
const min = (i % 2 === 0) ? "00" : "30";
378-
const timeKey = `${String(hour).padStart(2, '0')}:${min}`;
379-
380-
const txt = cell.innerText.trim();
381-
// В = Відключено (2), МЗ = Можливо заживлено -> Відключено (2), З = Заживлено (1)
382-
let status = 1;
383-
if (txt === 'В' || txt === 'МЗ') status = 2;
384-
385-
dailySchedule[timeKey] = status;
386-
});
387-
388-
if (!map[queueId]) map[queueId] = {};
389-
map[queueId][dateStr] = dailySchedule;
390-
});
391-
return map;
392-
});
393-
394-
await context.close();
395-
return schedule;
396-
397-
} catch (e) {
398-
console.warn(`⚠️ Error scraping Chernivtsi: ${e.message}`);
399-
await context.close();
400-
if (attempt === MAX_RETRIES) return null;
401-
await sleep(3000);
402-
}
403-
}
404-
}
405348

406349
// --- ТРАНСФОРМАЦІЇ ---
407350

0 commit comments

Comments
 (0)