From: Edward Delaporte Date: Sun, 14 Jun 2026 00:56:15 +0000 (-0500) Subject: Add some default zones X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-shop-bot.git/commitdiff_plain/e1202c785e427e7a9a45249ef1f81afe9760ed1d?ds=sidebyside;hp=0e5d4f7e16d7b8906e40f784190d63f298be120f Add some default zones --- diff --git a/CHANGELOG.md b/CHANGELOG.md index ee390b9..e936ac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/matrix_shop_bot/db.py b/matrix_shop_bot/db.py index 2f5b289..cd8d494 100644 --- a/matrix_shop_bot/db.py +++ b/matrix_shop_bot/db.py @@ -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'