]> apps.delaporte.us Git - matrix-shop-bot.git/commitdiff
Add some default zones
authorEdward Delaporte <edward@delaporte.us>
Sun, 14 Jun 2026 00:56:15 +0000 (19:56 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 14 Jun 2026 00:56:15 +0000 (19:56 -0500)
CHANGELOG.md
matrix_shop_bot/db.py

index ee390b98adb20d1156b67c5ba0ba1e18d72b28c2..e936ac4a0bb3d32ba5e99bd7b876f549eb6f3792 100644 (file)
@@ -1,9 +1,15 @@
 
-## Upcoming
+## 1.2.0 - 2026 June 13
 
 - Easier to copy shopping list.
 - Reduced notifications.
 - Zones are no longer case sensitive.
+- Items list alphabetically within each zone.
+- Zones can use partial matches.
+- Setup adds some default zones.
+
+> Zone: icecream -> dairy
+> will now match 'Chocolate Icecream' and 'Vanilla Icecream'
 
 ## 1.1.0 - 2026 June 6
 
index 2f5b28967cbe9f9bbc1e52411e9bdf16f818dec7..cd8d494cacfe16832b5cceee08c82d0f7c979f2c 100644 (file)
@@ -297,6 +297,34 @@ class Data():
 
     def setup(self):
         SQLModel.metadata.create_all(self.engine)
+        with Session(self.engine) as session:
+            # Add some obvious store zones by default
+            DEFAULT_ZONES = {
+                'Bakery': ['bread', 'cake', 'cookie', 'muffin', 'pie'],
+                'Baking': ['flour', 'sugar'],
+                'Books': ['book'],
+                'Clothes': ['bra', 'coat', 'jacket', 'panties', 'pants', 'shirt', 'shorts', 'socks', 'sweater', 'underwear'],
+                'Cooler': ['butter', 'cream', 'eggs', 'juice', 'milk', 'tea'],
+                'Deli': ['beef', 'chicken', 'salmon', 'steak', 'turkey'],
+                'Movies': ['movie', 'DVD'],
+                'Music': ['cd', 'album'],
+                'Produce': ['carrot', 'cucumber', 'greens', 'lettuce'],
+                'Shoes': ['shoe'],
+                'Television': ['tv', 'season'],
+            }
+            for zone in DEFAULT_ZONES:
+                logging.debug(f'Adding default items for {zone}')
+                for item in DEFAULT_ZONES[zone]:
+                    try:
+                        logging.debug(f'Attempt adding {item} to {zone}...')
+                        new = ItemZone(name=item, zone=zone)
+                        session.add(new)
+                        session.commit()
+                        logging.debug(f'Success adding {item} to {zone}...')
+                    except Exception as ex:
+                        session.rollback()
+                        logging.debug(f'Failed adding {item} to {zone}: {ex}')
+
         return 'Success'