]> us-delaporte.pagekite.me Git - matrix-shop-bot.git/blobdiff - matrix_shop_bot/db.py
Attempt at memoization
[matrix-shop-bot.git] / matrix_shop_bot / db.py
index 05ca9eb3157de33e2ca0046219b21646d532680b..bab18376ffbbff9205e93e84bf6a90b1822cebd2 100644 (file)
@@ -80,7 +80,7 @@ class Data():
             
     def add_item(self, name):
         item_id = self._add_with_name(Item, name)
-        if self.last_store_id:
+        if isinstance(self.last_store_id, int):
             with Session(self.engine) as session:
                 store_id = self.last_store_id
                 store = session.exec(_get_with_id(Store, store_id)).first()
@@ -132,7 +132,9 @@ class Data():
             return items
 
     def get_shopping_list(self, store_id=None) -> List[str]:
-        if not store_id:
+        if isinstance(store_id, int):
+            self.last_store_id = store_id
+        else:
             store_id = self.last_store_id
 
         results = []