"""Status string to display-glyph mappings. Ports the logic from the Vue StatusMixin so the Streamlit UI renders the same icons and legends as the legacy frontend. """ STATUS_GLYPHS = { 'ingested': '✅', 'sent': '✅', 'processed': '✅', 'not_available': '❌', 'active': '❌', 'not_ingested': '❗', 'failed': '❗', 'downloaded': '⬇', 'populated_raw_table': '🔁', 'processed_notif_sent': '🔁', 'on_hold': '🔁', 'cancelled': '🔁', 'ingested_extra': '☑️', 'ingested_warn': '⚠️', } MISSING_GLYPH = '--' CHIP_GLYPHS = { 'ok': '🟢', 'critical': '🔴', 'pending': '⚪', } LEGENDS = { 'ingestion': [ ('✅', 'Ingested'), ('❌', 'Not available'), ('❗', 'Not ingested'), ('⬇', 'Downloaded'), ('🔁', 'populated_raw_table'), ], 'outgoing': [ ('✅', 'Sent'), ], 'activity_detector': [ ('✅', 'Processed'), ('🔁', 'Processed, notification sent'), ], 'delphi': [ ('✅', 'Ingested'), ('☑️', 'Ingested: min or force complete'), ('⚠️', 'Ingested, some units still pending'), ('❌', 'Not available'), ('❗', 'Not ingested'), ], } def status_glyph(status): """Return the emoji glyph for a feed-day status, or '--' when missing.""" if not status: return MISSING_GLYPH if status == '--': return status return STATUS_GLYPHS.get(status, status) def chip_label(status): """Return 'emoji + status word' for Fresh/Stable cells.""" glyph = CHIP_GLYPHS.get(status) if not glyph: return '' return f'{glyph} {status}'