feat: add schedule import functionality and quality control page

- Implemented the schedule import feature with a dedicated page for importing schedules from the transport website.
- Added a new QualityPage to check the quality of routes, stops, schedules, and notifications without making automatic changes.
- Created CSS styles for both the ScheduleImportPage and QualityPage to enhance the user interface.
- Introduced API calls for fetching schedule data and quality reports.
- Added error handling and loading states for better user experience during data fetching.
- Included functionality for filtering quality issues and displaying detailed reports.
This commit is contained in:
2026-09-16 21:55:50 +03:00
parent 6804ca5cdb
commit 595ad6456b
36 changed files with 2496 additions and 72 deletions

View File

@@ -0,0 +1,24 @@
-- Import previews are immutable snapshots; applying one is an explicit admin action.
CREATE TABLE IF NOT EXISTS schedule_imports (
id UUID PRIMARY KEY,
route_id INTEGER REFERENCES routes(id) ON DELETE SET NULL,
source_url TEXT NOT NULL,
source_hash TEXT NOT NULL,
source JSONB NOT NULL,
status TEXT NOT NULL CHECK (status IN ('inspection', 'ready', 'applied')),
payload JSONB,
created_by INTEGER,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
applied_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_schedule_imports_created ON schedule_imports(created_at DESC);
CREATE TABLE IF NOT EXISTS schedule_import_news (
url TEXT PRIMARY KEY,
title TEXT NOT NULL,
published_date TEXT,
content TEXT NOT NULL,
content_hash TEXT NOT NULL,
reviewed_hash TEXT,
checked_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

View File

@@ -0,0 +1,19 @@
-- Delivery state is separate from visibility. A scheduled alert becomes visible
-- at start_time; this state makes sure its push notification is sent once.
ALTER TABLE alerts
ADD COLUMN IF NOT EXISTS notification_sent_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS notification_claimed_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS notification_attempts INTEGER NOT NULL DEFAULT 0;
CREATE INDEX IF NOT EXISTS idx_alerts_pending_notification
ON alerts (start_time)
WHERE is_active = true AND notification_sent_at IS NULL;
-- Earlier versions sent every active alert immediately on creation. Mark those
-- already-created future alerts as dispatched, so upgrading does not notify
-- passengers a second time when the scheduler starts.
UPDATE alerts
SET notification_sent_at = created_at
WHERE notification_sent_at IS NULL
AND is_active = true
AND start_time > created_at;