mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -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:
@@ -40,7 +40,7 @@ from app.models import (
|
||||
)
|
||||
from app.service.statistics import format_monthly_template_notification_stats
|
||||
from app.statsd_decorators import statsd
|
||||
from app.utils import get_london_month_from_utc_column, get_london_midnight_in_utc, get_london_year_from_utc_column
|
||||
from app.utils import get_london_month_from_utc_column, get_london_midnight_in_utc
|
||||
from app.dao.annual_billing_dao import dao_insert_annual_billing
|
||||
|
||||
DEFAULT_SERVICE_PERMISSIONS = [
|
||||
@@ -525,13 +525,13 @@ def dao_fetch_active_users_for_service(service_id):
|
||||
@statsd(namespace="dao")
|
||||
def dao_fetch_monthly_historical_stats_by_template():
|
||||
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
||||
year = get_london_year_from_utc_column(NotificationHistory.created_at)
|
||||
year = func.date_trunc("year", NotificationHistory.created_at)
|
||||
end_date = datetime.combine(date.today(), time.min)
|
||||
|
||||
return db.session.query(
|
||||
NotificationHistory.template_id,
|
||||
month.label('month'),
|
||||
year.label('year'),
|
||||
extract('month', month).label('month'),
|
||||
extract('year', year).label('year'),
|
||||
func.count().label('count')
|
||||
).filter(
|
||||
NotificationHistory.created_at < end_date
|
||||
|
||||
Reference in New Issue
Block a user