mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Updates after review
- Modified the services_dao to return an int instead of a datetime to make usage easier and removed the BST function on year as it is not relevant for year - Improved tests do there is less logic by ordering the result so there is less reliance on the template id - Renamed variable in stats_template_usage_by_month_dao.py to make it consistent with the method
This commit is contained in:
18
app/utils.py
18
app/utils.py
@@ -71,23 +71,7 @@ def get_london_month_from_utc_column(column):
|
||||
"""
|
||||
return func.date_trunc(
|
||||
"month",
|
||||
func.timezone("Europe/London", func.timezone("UTC", column))
|
||||
)
|
||||
|
||||
|
||||
def get_london_year_from_utc_column(column):
|
||||
"""
|
||||
Where queries need to count notifications by month it needs to be
|
||||
the month in BST (British Summer Time).
|
||||
The database stores all timestamps as UTC without the timezone.
|
||||
- First set the timezone on created_at to UTC
|
||||
- then convert the timezone to BST (or Europe/London)
|
||||
- lastly truncate the datetime to month with which we can group
|
||||
queries
|
||||
"""
|
||||
return func.date_trunc(
|
||||
"month",
|
||||
func.timezone("Europe/London", func.timezone("UTC", column))
|
||||
func.timezone("Europe/London", column)
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user