From 5402e3a2e9df24a883e2e20dfae6c92f11b8d499 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 22 Feb 2023 23:57:11 -0800 Subject: bot: change create_poi to create_or_update_poi --- dbstore/peewee_store.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'dbstore') diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py index 00897d7..89e4b4b 100644 --- a/dbstore/peewee_store.py +++ b/dbstore/peewee_store.py @@ -52,14 +52,13 @@ def get_poi_by_fsq_id(fsq_id) -> dict: return {} -def create_poi(poi: dict): +def create_or_update_poi(poi: dict) -> int: with db.connection_context(): - poi = Location.create( + return Location.insert( fsq_id=poi["fsq_id"], name=poi["name"], locality=poi["locality"], region=poi["region"], latitude=poi["latitude"], longitude=poi["longitude"], - ) - poi.save() + ).on_conflict_replace().execute() -- cgit v1.2.3