Files
awesome-kubernetes/scripts/backfill_discovered_at.py
Nubenetes Bot 4e87c248fd feat: implement AI-powered news digest engine, MkDocs UX overhaul, pipeline hardening, and stub page merges
- Add 26-category news digest engine (src/news_digest.py) with Gemini AI ranking
  for 3/6/12 month temporal panels across tech, cloud, and geo categories
- Add discovered_at, company, geo_region fields to inventory schema with backfill
  script populating 18K+ existing entries
- Fix critical v2-mkdocs.yml bug: plugins were nested under theme (silently disabled)
- Add MkDocs Material features: instant nav, breadcrumbs, footer, announce bar
- Add trending cards CSS grid and replace Agentic Pulse with dynamic Trending Now
- Generate tech-digest.md and industry-digest.md with tabbed 3/6/12 month views
- Merge 12 stub pages (<40 lines each) into parent categories with redirects
- Replace 50 bare except:pass patterns with contextual logging across all pipeline files
- Expand autonomous discovery from 6 to 14 GitHub search queries
- Add stale health re-check for online entries older than 30 days
- Track addition_method by source type (rss, twitter, github_trending)
- Add digest generation step to CI publish workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-19 00:38:56 +02:00

60 lines
1.8 KiB
Python

"""
Backfill script: adds discovered_at to inventory entries that lack it.
Priority: gh_pushed > last_checked > year > default "2024-01-01T00:00:00"
Run once: python -m scripts.backfill_discovered_at
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from datetime import datetime
from src.inventory_manager import load_inventory, save_inventory
from src.config import MADRID_TZ
def backfill():
inv = load_inventory()
updated = 0
total = 0
for url, entry in inv.items():
if not isinstance(entry, dict):
continue
total += 1
if entry.get("discovered_at"):
continue
discovered = None
gh_pushed = entry.get("gh_pushed")
if gh_pushed and isinstance(gh_pushed, str) and len(gh_pushed) >= 10:
discovered = gh_pushed
if not discovered:
last_checked = entry.get("last_checked")
if isinstance(last_checked, (int, float)) and last_checked > 0:
try:
discovered = datetime.fromtimestamp(last_checked, tz=MADRID_TZ).isoformat()
except (OSError, ValueError):
pass
if not discovered:
year = entry.get("year", "")
if isinstance(year, str) and year.isdigit() and len(year) == 4:
discovered = f"{year}-06-01T00:00:00+02:00"
elif isinstance(year, int):
discovered = f"{year}-06-01T00:00:00+02:00"
if not discovered:
discovered = "2024-01-01T00:00:00+02:00"
entry["discovered_at"] = discovered
updated += 1
print(f"Backfill complete: {updated}/{total} entries updated with discovered_at")
save_inventory(inv)
if __name__ == "__main__":
backfill()