From be91c6f7e2e14ba143f3143c0923b3523ae4ad11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Alloza=20Gonz=C3=A1lez?= Date: Wed, 13 Oct 2021 20:23:00 +0200 Subject: [PATCH] feat: show day after tomorrow's menu in notion (#6) * feat: show day after tomorrow's meals in notion * fix: predefined 3 notion blocks * chore: version bump --- app/cron/update_notion_meals.py | 8 +++++++- app/crud/crud_meal.py | 3 +++ pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/cron/update_notion_meals.py b/app/cron/update_notion_meals.py index 69c63b1..d809e59 100644 --- a/app/cron/update_notion_meals.py +++ b/app/cron/update_notion_meals.py @@ -11,9 +11,11 @@ def update_notion_meals(): with manual_db() as db: today_meal = crud.meal.get_today(db) tomorrow_meal = crud.meal.get_tomorrow(db) + dat_meal = crud.meal.get_day_after_tomorrow(db) today_meal = Meal.from_orm(today_meal) if today_meal else None tomorrow_meal = Meal.from_orm(tomorrow_meal) if tomorrow_meal else None + dat_meal = Meal.from_orm(dat_meal) if dat_meal else None blocks = [] blocks.append(create_notion_block("Hoy\n", bold=True)) @@ -24,7 +26,11 @@ def update_notion_meals(): if tomorrow_meal: blocks.extend(tomorrow_meal.to_notion_blocks()) - if len(blocks) <= 2: + blocks.append(create_notion_block("\nPasado mañana\n", bold=True)) + if dat_meal: + blocks.extend(dat_meal.to_notion_blocks()) + + if len(blocks) <= 3: print("warning: not blocks detected in cron-script update-notion-meals") return diff --git a/app/crud/crud_meal.py b/app/crud/crud_meal.py index 77d8d13..83d8933 100644 --- a/app/crud/crud_meal.py +++ b/app/crud/crud_meal.py @@ -45,6 +45,9 @@ def get_today(self, db: Session): def get_tomorrow(self, db: Session): return self.get_by_date_delta(db, delta_days=1) + def get_day_after_tomorrow(self, db: Session): + return self.get_by_date_delta(db, delta_days=2) + def get_week(self, db: Session, *, week: int): return db.query(self.model).filter(func.weekofyear(self.model.id) == week).all() diff --git a/pyproject.toml b/pyproject.toml index ec61885..096d13d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "meal-planner" -version = "1.0.1" +version = "1.1.0" description = "" authors = ["Diego Alloza González "] packages = [