X-Git-Url: https://apps.delaporte.us/gitweb/matrix-shop-bot.git/blobdiff_plain/d0f8d69f2d4aa2a1af67baae391663d9bb72c729..8b639943d820c97787fed92731f0ec8d13e9ac7e:/matrix_shop_bot/tasks.py diff --git a/matrix_shop_bot/tasks.py b/matrix_shop_bot/tasks.py index 1fbc3fb..6b999bf 100644 --- a/matrix_shop_bot/tasks.py +++ b/matrix_shop_bot/tasks.py @@ -1,7 +1,11 @@ from invoke import task +import logging from .db import Data +logging.getLogger('invoke').setLevel(logging.WARNING) +logging.basicConfig(filename=f'matrix-shop-bot.log', encoding='utf-8', level=logging.DEBUG) + @task def setup(c): result = Data().setup() @@ -17,30 +21,59 @@ def add_store(c, name): result = Data().add_store(name) print(result) + +@task +def assign(c, item_id): + result = Data().assign_last_store(item_id) + print(result) + + @task -def buy(c, item_id): - result = Data().purchase_item(item_id) +def assign_to_store(c, item_id, store_id): + result = Data().assign_store(store_id, item_id) print(result) + @task -def list(c, store_id): - items = Data().get_shopping_list(store_id) +def buy(c, items): + result = Data().purchase_items(items) + print(result) + +@task +def list_bought(c, store): + result = Data().list_purchases(store) + for item in result: + print(str(item)) + +@task +def clear_all(c, store_id): + Data().clear_list(store_id, clear_all=True) + +@task +def clear_list(c, store_id): + Data().clear_list(store_id) + + +@task +def at(c, store_name): + '''Select store to shop at''' + items = Data().get_shopping_list(store_name) for item in items: print(item) @task -def list_stores(c): - items = Data().get_stores() +def list(c): + '''Use previous store''' + items = Data().get_last_shopping_list() for item in items: print(item) @task -def clear_list(c, store_id): - Data().clear_list(store_id) +def list_stores(c): + items = Data().get_stores() + for item in items: + print(item) -@task -def clear_all(c, store_id): - Data().clear_list(store_id, clear_all=True) @task def list_unsorted(c): @@ -48,9 +81,12 @@ def list_unsorted(c): for item in items: print(item) + @task -def assign(c, store_id, item_id): - result = Data().assign_store(store_id, item_id) - print(result) +def remove_item(c, item_id): + Data().remove_item(item_id) +@task +def remove_store(c, store_id): + Data().remove_store(store_id)