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 = [