From f8f2be4d85cdcd2b83a0840ad876a489931417e4 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Thu, 3 Oct 2024 09:51:11 +0530 Subject: [PATCH] dashboard: Add comment explaining use of (0, 13) for All --- app/pages/dashboard.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/pages/dashboard.py b/app/pages/dashboard.py index 20be605..70f1c99 100644 --- a/app/pages/dashboard.py +++ b/app/pages/dashboard.py @@ -139,8 +139,12 @@ def get_months() -> list[tuple[int, int]]: sql = "SELECT date FROM expense" data = pd.read_sql_query(sql, engine, parse_dates=["date"]) months = set(data["date"].apply(lambda x: (x.year, x.month))) + # NOTE: We use month 13 to represent the whole year years = {(y, 13) for (y, _) in months} months_sorted = sorted(months.union(years), reverse=True) + # NOTE: We use (0, 13) to represent All. We need explicit numbers to + # indicate selection, since we want to select the (current_year, + # current_month) when year and month are (None, None). return [(0, 13), *months_sorted]