fix(webui): timeline opens on full landscape, drop undated points
After the chronological-order fix the page opened on the earliest month
(1995-12), showing only a handful of same-colored dots while the legend
listed every category — looked broken.
- Initialise the plot on the LAST frame (full landscape); Play now replays
the build-up from the start (fromcurrent: false), slider starts at the end.
- Make _extract_month robust: year-only / junk dates (ISO/ETSI 'time' like
'2015/CD Amd 2', bare '2023', '') no longer yield malformed month labels
('2015-/C') or a garbled 'unknown' frame badge.
- Drop undated docs from the temporal animation (they remain on /landscape).
At the full initial frame every category has points, so the legend matches
what is drawn.
This commit is contained in:
@@ -20,14 +20,17 @@ _CACHE_TTL = 300 # 5 minutes
|
||||
|
||||
|
||||
def _extract_month(time_str: str | None) -> str:
|
||||
"""Normalize a date string to YYYY-MM format."""
|
||||
"""Normalize a date string to YYYY-MM (or "unknown" if unparseable)."""
|
||||
if not time_str:
|
||||
return "unknown"
|
||||
if len(time_str) >= 7 and time_str[4] == '-':
|
||||
return time_str[:7] # Already YYYY-MM-DD
|
||||
if len(time_str) >= 6 and time_str[:4].isdigit():
|
||||
return time_str[:4] + '-' + time_str[4:6] # YYYYMMDD → YYYY-MM
|
||||
return time_str[:7]
|
||||
s = time_str.strip()
|
||||
if len(s) >= 7 and s[4] == '-' and s[5:7].isdigit():
|
||||
return s[:7] # ISO 8601: YYYY-MM-DD...
|
||||
if len(s) >= 6 and s[:6].isdigit():
|
||||
return s[:4] + '-' + s[4:6] # Compact: YYYYMMDD → YYYY-MM
|
||||
if len(s) >= 4 and s[:4].isdigit():
|
||||
return s[:4] + '-01' # Year-only / year-prefixed junk (e.g. "2015/CD Amd 2")
|
||||
return "unknown"
|
||||
|
||||
def _cached(key: str, fn, ttl: float = _CACHE_TTL):
|
||||
"""Return cached result or compute and cache it."""
|
||||
|
||||
@@ -546,6 +546,8 @@ def _compute_timeline_animation_data(db: Database) -> dict:
|
||||
r = rating_map[name]
|
||||
d = draft_map.get(name)
|
||||
month = _extract_month(d.time if d else None)
|
||||
if month == "unknown":
|
||||
continue # Undated docs (e.g. ISO/ETSI) can't be placed on a temporal animation
|
||||
cat = r.categories[0] if r.categories else "Other"
|
||||
month_set.add(month)
|
||||
category_monthly[month][cat] += 1
|
||||
|
||||
Reference in New Issue
Block a user