Skip to content

perf(dashboard): trim logs to first+last 3 and slim top-level news#62

Merged
nullhack merged 1 commit into
mainfrom
fix/trim-logs-slim-news
Jul 24, 2026
Merged

perf(dashboard): trim logs to first+last 3 and slim top-level news#62
nullhack merged 1 commit into
mainfrom
fix/trim-logs-slim-news

Conversation

@nullhack

Copy link
Copy Markdown
Owner

Problem

Daily JSON files were 65% larger than necessary (877KB → 305KB on the largest day). Two sources of bloat:

  1. Logs: every incident shipped its FULL log timeline (up to 11 logs with 139+ news items for long-running incidents like Venezuela). Drawer timeline was correspondingly very long.

  2. Top-level news array: carried full 7-field dicts per news item, but the frontend only uses headline (search haystack) and published_date (recent activity filter) when logs exist. The full dicts are never rendered — the drawer timeline reads from logs[].news[] instead.

Changes

scripts/generate_dashboard_data.py

  • Added MAX_RECENT_LOGS = 3 constant
  • Logs trimmed to [first_log] + last_3_logs when len > 4
  • Added logs_total field to incident dict (original count before trimming)
  • Top-level news array slimmed to {headline, published_date} when logs exist; full dicts kept when no logs (drawer fallback)
  • SCHEMA_VERSION bumped to 1.5

dashboard/app.js

  • Extracted timeline rendering into _logEntryHtml(log) + _timelineHtml(logs, logsTotal) helpers
  • ⋮ separator inserted between recent logs and genesis log when trimmed
  • Header reads Timeline · 4 of 11 log(s) when trimmed
  • Tooltip on separator: N log(s) hidden

dashboard/styles.css

  • .log-entry--gap: centered muted ⋮ with bottom border

Impact

Day Before After Savings
2026-07-22 877KB 305KB 65%

Only 24 of 1065 incident-appearances across all daily JSONs have >4 logs — most incidents are unaffected. Search and recent activity tabs work unchanged (they only need headline + published_date).

Daily JSON files were 65% larger than necessary (877KB → 305KB on the
largest day) due to two sources of bloat:

1. Logs: every incident shipped its FULL log timeline (up to 11 logs with
   139+ news items for long-running incidents like Venezuela). Now trimmed
   to first log (genesis) + last 3 logs (recent activity). Frontend shows
   a ⋮ separator with a tooltip indicating how many logs were hidden.
   Header reads '4 of 11 log(s)' instead of '11 log(s)'.

2. Top-level news array: carried full 7-field dicts (url, body, image,
   outlet...) per news item, but the frontend only uses headline (search
   haystack) and published_date (recent activity filter) when logs exist.
   Now slimmed to {headline, published_date} when logs exist — the full
   dicts in logs[].news[] are unchanged (drawer timeline reads from there).

Added logs_total field to incident dict so the frontend can detect
trimming. SCHEMA_VERSION bumped to 1.5.
@nullhack
nullhack merged commit 0732ad4 into main Jul 24, 2026
1 check passed
@nullhack
nullhack deleted the fix/trim-logs-slim-news branch July 24, 2026 08:46
nullhack added a commit that referenced this pull request Jul 24, 2026
Dashboard data regenerated with log trimming and news slimming.
65% size reduction on the largest daily JSON (877KB → 305KB).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant