Skip to content

Commit

Permalink
only return holidays within date range
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Jul 16, 2024
1 parent 18a8ed0 commit ba4c0ed
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions backend/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,24 @@ def get_date_bounds():
def get_holidays():
"Return dates of all known holidays in ascending order"
connection = getConnection()
query = f"""
SELECT
dt::text,
EXTRACT(ISODOW FROM dt)::int,
holiday
FROM ref.holiday
WHERE dt >= %(minDate)s AND dt < %(maxDate)s
ORDER BY dt;
"""
with connection:
with connection.cursor() as cursor:
cursor.execute(
"SELECT dt::text, EXTRACT(ISODOW FROM dt)::int, holiday FROM ref.holiday ORDER BY dt;"
)
dates = [{'date': dt, 'dow': dow, 'name': nm} for (dt, dow, nm) in cursor.fetchall()]
cursor.execute(query, get_date_bounds())
dates = [
{
'date': dt,
'dow': dow,
'name': nm
} for (dt, dow, nm) in cursor.fetchall()
]
connection.close()
return dates

0 comments on commit ba4c0ed

Please sign in to comment.