Release 0.58.0 includes the Earth high-precision boundary PMTiles/MVT pipeline, standardized Earth boundary source collectors, China POV boundary configuration templates, and removal of the legacy low-precision GeoJSON fallback. It also adds Earth news target-location queueing/archive support, fixes datasource task status visibility, documents the Earth surface depth-spacing rules that prevent far-zoom z-fighting snow/black blocks, and updates bilingual operations/developer docs.
58 lines
2.4 KiB
Python
58 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.services.collectors.base import BaseCollector
|
|
from app.services.earth_news_store import list_all_earth_news_records
|
|
|
|
|
|
class MediaNewsArchiveCollector(BaseCollector):
|
|
name = "media_news_archive"
|
|
priority = "P2"
|
|
module = "L4"
|
|
frequency_hours = 12
|
|
data_type = "news_item"
|
|
fail_on_empty = False
|
|
|
|
async def fetch(self) -> list[dict[str, Any]]:
|
|
if not self._db_session:
|
|
return []
|
|
|
|
records = await list_all_earth_news_records(self._db_session)
|
|
items: list[dict[str, Any]] = []
|
|
for record in records:
|
|
location_meta = dict(record.location_meta or {})
|
|
target = location_meta.get("target") if isinstance(location_meta.get("target"), dict) else {}
|
|
country = target.get("country")
|
|
city = target.get("city")
|
|
items.append(
|
|
{
|
|
"id": record.id,
|
|
"source_id": record.id,
|
|
"name": record.title,
|
|
"title": record.title,
|
|
"description": record.summary,
|
|
"country": country,
|
|
"city": city,
|
|
"latitude": record.latitude,
|
|
"longitude": record.longitude,
|
|
"reference_date": record.published_at,
|
|
"metadata": {
|
|
"url": record.url,
|
|
"source": record.source,
|
|
"feed_name": record.feed_name,
|
|
"region": record.region,
|
|
"homepage_url": record.homepage_url,
|
|
"published_at": record.published_at.isoformat() if record.published_at else None,
|
|
"location_label": record.location_label,
|
|
"location_source": record.location_source,
|
|
"verified": record.verified,
|
|
"location_meta": location_meta,
|
|
"first_seen_at": record.first_seen_at.isoformat() if record.first_seen_at else None,
|
|
"last_seen_at": record.last_seen_at.isoformat() if record.last_seen_at else None,
|
|
"resolved_at": record.resolved_at.isoformat() if record.resolved_at else None,
|
|
},
|
|
}
|
|
)
|
|
return items
|