Upload deploy/ingest/aggregate.py with huggingface_hub
Browse files55 unmodified lines565758596061626364656612 unmodified lines798081828384858620 unmodified lines10710810911011111255 unmodified linesnow = datetime.now(timezone.utc)since24 = (now - timedelta(hours=24)).strftime("%Y-%m-%d")# 1. 最近 24 小时事件点(按影响度排序,取前 600)cur = con.execute("SELECT lat, lon, category, country, mentions, goldstein, tone, title, url, ts, src ""FROM events WHERE date >= ? AND lat IS NOT NULL ""ORDER BY mentions DESC, ts DESC LIMIT 600", (since24,))pts = []for lat, lon, cat, ctry, men, gold, tone, title, url, ts, src in cur:pts.append({12 unmodified lines# 3. 国家排行(按事件压力加权)cur = con.execute("SELECT country, SUM(n), SUM(epi) FROM daily WHERE date >= ? ""GROUP BY country ORDER BY 3 DESC LIMIT 25", (since24,))countries = [{"cc": FIPS.get(c, c), "n": n, "epi": round(e, 1)} for c, n, e in cur]# 4. 每日指数序列(过去 30 天的 EPI 与事件数)cur = con.execute(20 unmodified lines"countries": len(countries),"categories": cats,"top_countries": countries,"series": series,"frames": frames,"sources": ["GDELT 2.0", "USGS", "NASA EONET"],55 unmodified lines565758596061626364656612 unmodified lines79808182838485868720 unmodified lines10810911011111211311455 unmodified linesnow = datetime.now(timezone.utc)since24 = (now - timedelta(hours=24)).strftime("%Y-%m-%d")# 1. 最近 24 小时事件点(按影响度排序,取前 2000)cur = con.execute("SELECT lat, lon, category, country, mentions, goldstein, tone, title, url, ts, src ""FROM events WHERE date >= ? AND lat IS NOT NULL ""ORDER BY mentions DESC, ts DESC LIMIT 2000", (since24,))pts = []for lat, lon, cat, ctry, men, gold, tone, title, url, ts, src in cur:pts.append({12 unmodified lines# 3. 国家排行(按事件压力加权)cur = con.execute("SELECT country, SUM(n), SUM(epi) FROM daily WHERE date >= ? ""GROUP BY country ORDER BY 3 DESC", (since24,))allc = [{"f": c, "cc": FIPS.get(c, c), "n": n, "epi": round(e, 1)} for c, n, e in cur]countries = allc[:25]# 4. 每日指数序列(过去 30 天的 EPI 与事件数)cur = con.execute(20 unmodified lines"countries": len(countries),"categories": cats,"top_countries": countries,"all_countries": allc,"series": series,"frames": frames,"sources": ["GDELT 2.0", "USGS", "NASA EONET"],
deploy/ingest/aggregate.py+6-4