Return financial year not calendar and ensure double precision values

are not returned from queries

- Updated stats_template_usage_by_month_dao.py to return the results for
financial year not calendar, as the report os for FY only and hence
only the FY data is required
- Updated services_dao.py to ensure double precision values are converted
to an int as the 'exact' function returns double precision from the
database query, as the admin code requires the value for month to be an
int
This commit is contained in:
Richard Chapman
2017-11-20 10:01:45 +00:00
parent b56825a680
commit 58b0658a13
4 changed files with 210 additions and 31 deletions

View File

@@ -1,3 +1,5 @@
from sqlalchemy import or_, and_
from app import db
from app.statsd_decorators import statsd
from app.dao.dao_utils import transactional
@@ -41,6 +43,15 @@ def dao_get_template_usage_stats_by_service(service_id, year):
).join(
Template, StatsTemplateUsageByMonth.template_id == Template.id
).filter(
Template.service_id == service_id,
StatsTemplateUsageByMonth.year == year
Template.service_id == service_id
).filter(
or_(
and_(
StatsTemplateUsageByMonth.month.in_([4, 5, 6, 7, 8, 9, 10, 11, 12]),
StatsTemplateUsageByMonth.year == year
), and_(
StatsTemplateUsageByMonth.month.in_([1, 2, 3]),
StatsTemplateUsageByMonth.year == year + 1
)
)
).all()