mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-06-10 08:54:34 +02:00
HTTP wrapper over the wiki_index lookup so the (future) navi-places service can
fetch wiki enrichment over HTTP instead of reading recon's 2.1 GB
data/wiki_index.db directly (Phase A option B — HTTP coupling).
GET /api/wiki-enrich?wikidata=<Qid> (primary key)
GET /api/wiki-enrich?name=<name>&country=<cc> (fallback key)
-> 200 {wiki_summary?, wiki_population?, wiki_url?, wikivoyage_url?}
-> 400 if no usable key; 404 on no match. Public (no auth, like /api/place/*).
Route keys are wikidata_id / name+country — NOT osm_type/osm_id — because that
is how wiki_index is actually queried (the in-process _enrich_with_wiki_index
looks up by result['wikidata_id'] then name+country_code, never by OSM id; see
extraction-5-wiki-enrich-investigation.md). An osm-keyed route would have forced
a redundant in-recon place lookup.
Changes (additive only):
- lib/place_detail.py: new standalone lookup_wiki_index(wikidata_id, name,
country_code) doing the same two SELECTs + field/URL mapping as the
in-process path, returning a dict or None. Pure DB read, never raises.
`_enrich_with_wiki_index` is LEFT UNTOUCHED — it can be DRY-refactored to
delegate to this in a later PR; the in-process enrichment path is unchanged.
- lib/wiki_enrich_api.py: new wiki_enrich_bp blueprint with the route.
- lib/api.py: register the blueprint (one block).
- lib/wiki_enrich_api_test.py: 4 tests (hit-by-wikidata + decoded fields,
no-match -> 404, name+country fallback, no-key -> 400) over an in-memory
fixture DB; plain-assert style + __main__ runner (recon venv has no pytest).
Verified green against recon's venv (flask 3.1.2).
Does NOT remove the in-process _enrich_with_wiki_index call from place_detail —
that happens in a later PR once navi-places is live and serving.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| acquisition | ||
| offroute | ||
| processors | ||
| __init__.py | ||
| address_book.py | ||
| address_book_api.py | ||
| address_book_test.py | ||
| api.py | ||
| api_keys_admin.py | ||
| aurora_nav_tool.py | ||
| auth.py | ||
| contacts.py | ||
| contacts_api.py | ||
| deployment_config.py | ||
| dispatcher.py | ||
| embedder.py | ||
| enricher.py | ||
| extractor.py | ||
| filing.py | ||
| geocode.py | ||
| geocode_test.py | ||
| google_places.py | ||
| ingester.py | ||
| key_manager.py | ||
| landclass.py | ||
| landclass_test.py | ||
| nav_tools.py | ||
| nav_tools_test.py | ||
| netsyms.py | ||
| netsyms_api.py | ||
| netsyms_test.py | ||
| new_pipeline.py | ||
| organizer.py | ||
| osm_categories.py | ||
| overture.py | ||
| peertube_collector.py | ||
| peertube_scraper.py | ||
| place_detail.py | ||
| query_router.py | ||
| query_router_test.py | ||
| reverse_bundle_test.py | ||
| scraper_runner.py | ||
| status.py | ||
| utils.py | ||
| web_scraper.py | ||
| wiki_enrich_api.py | ||
| wiki_enrich_api_test.py | ||
| wiki_rewrite.py | ||
| zim_monitor.py | ||