From 938f79ba19340434f92b284623edaef4da494ba6 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 19 Jun 2024 14:23:20 +0100 Subject: [PATCH] Bug fix refresh_item --- web_view.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_view.py b/web_view.py index 03ab0f3..4a2edac 100755 --- a/web_view.py +++ b/web_view.py @@ -676,7 +676,7 @@ def api_polygon(osm_type, osm_id): @app.route("/refresh/Q") def refresh_item(item_id: int) -> str: """Refresh the local mirror of a Wikidata item.""" - existing = model.Item.query.get(item_id) + item = model.Item.query.get(item_id) qid = f"Q{item_id}" entity = wikidata_api.get_entity(qid) @@ -686,9 +686,9 @@ def refresh_item(item_id: int) -> str: coords = wikidata.get_entity_coords(entity["claims"]) obj = {k: v for k, v in entity.items() if k in entity_keys} - if existing: + if item: for k, v in obj.items(): - setattr(model, k, v) + setattr(item, k, v) else: item = model.Item(item_id=item_id, **obj) database.session.add(item)