Skip to content

Commit

Permalink
dashboard: Add comment explaining use of (0, 13) for All
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed Oct 3, 2024
1 parent 082bc8a commit f8f2be4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down

0 comments on commit f8f2be4

Please sign in to comment.