-
Notifications
You must be signed in to change notification settings - Fork 0
fix: staffMonitor pill visibility — robust parsing, error logging, fuzzy flight matching #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,10 @@ export async function fetchStaffMonitorData(nature: 'D' | 'A'): Promise<StaffMon | |
| try { | ||
| const url = `https://servizi.pisa-airport.com/staffMonitor/staffMonitor?trans=true&nature=${nature}`; | ||
| const resp = await fetch(url); | ||
| if (!resp.ok) return []; | ||
| if (!resp.ok) { | ||
| console.warn(`[staffMonitor] HTTP error for nature=${nature}: ${resp.status} ${resp.statusText}`); | ||
| return []; | ||
| } | ||
|
Comment on lines
+50
to
+53
|
||
| const html = await resp.text(); | ||
|
|
||
| const results: StaffMonitorFlight[] = []; | ||
|
|
@@ -56,8 +59,8 @@ export async function fetchStaffMonitorData(nature: 'D' | 'A'): Promise<StaffMon | |
|
|
||
| while ((match = trRegex.exec(html)) !== null) { | ||
| const rowHTML = match[1]; | ||
| // Only rows that carry a flight number cell | ||
| if (!/class="clsFlight"/i.test(rowHTML) && !/class='clsFlight'/i.test(rowHTML)) continue; | ||
| // Only rows that carry a flight number cell (match clsFlight as a substring of the class attribute) | ||
| if (!/class\s*=\s*["'][^"']*clsFlight[^"']*["']/i.test(rowHTML)) continue; | ||
|
|
||
| const cells = extractTDCells(rowHTML); | ||
| if (cells.length < 2) continue; | ||
|
|
@@ -83,8 +86,13 @@ export async function fetchStaffMonitorData(nature: 'D' | 'A'): Promise<StaffMon | |
| } | ||
| } | ||
|
|
||
| if (__DEV__) { | ||
| console.log(`[staffMonitor] nature=${nature} parsed ${results.length} flights.`, results.slice(0, 5).map(r => r.flightNumber)); | ||
| } | ||
|
|
||
| return results; | ||
| } catch { | ||
| } catch (e) { | ||
| console.error(`[staffMonitor] fetch/parse error for nature=${nature}:`, e); | ||
| return []; | ||
|
Comment on lines
+94
to
96
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderFlightnow does up to two linear scans ofsmPoolper rendered item. With a non-trivial number of flights this becomes O(renderedFlights × staffMonitorFlights) work during renders. Consider precomputing a lookup map (exact and stripped keys) withuseMemowhenstaffMonitorDeps/Arrschanges, and then doing O(1) lookups insiderenderFlight.