mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Refactor is_precompiled_letter to model
This commit is contained in:
@@ -83,7 +83,7 @@ def dao_get_template_usage(service_id, limit_days=None):
|
||||
Template.id.label('template_id'),
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
Template.hidden,
|
||||
Template.is_precompiled_letter,
|
||||
notifications_aggregate_query.c.count
|
||||
).join(
|
||||
notifications_aggregate_query,
|
||||
|
||||
@@ -522,7 +522,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
stat.month = result.month
|
||||
stat.year = result.year
|
||||
stat.count = result.count
|
||||
stat.hidden = result.hidden
|
||||
stat.is_precompiled_letter = result.is_precompiled_letter
|
||||
stats.append(stat)
|
||||
|
||||
month = get_london_month_from_utc_column(Notification.created_at)
|
||||
@@ -534,7 +534,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
if fy_start < datetime.now() < fy_end:
|
||||
today_results = db.session.query(
|
||||
Notification.template_id,
|
||||
Template.hidden,
|
||||
Template.is_precompiled_letter,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
extract('month', month).label('month'),
|
||||
@@ -574,7 +574,7 @@ def dao_fetch_monthly_historical_usage_by_template_for_service(service_id, year)
|
||||
new_stat.month = int(today_result.month)
|
||||
new_stat.year = int(today_result.year)
|
||||
new_stat.count = today_result.count
|
||||
new_stat.hidden = today_result.hidden
|
||||
new_stat.is_precompiled_letter = today_result.is_precompiled_letter
|
||||
stats.append(new_stat)
|
||||
|
||||
return stats
|
||||
|
||||
@@ -35,9 +35,9 @@ def insert_or_update_stats_for_template(template_id, month, year, count):
|
||||
def dao_get_template_usage_stats_by_service(service_id, year):
|
||||
return db.session.query(
|
||||
StatsTemplateUsageByMonth.template_id,
|
||||
Template.hidden,
|
||||
Template.name,
|
||||
Template.template_type,
|
||||
Template.is_precompiled_letter,
|
||||
StatsTemplateUsageByMonth.month,
|
||||
StatsTemplateUsageByMonth.year,
|
||||
StatsTemplateUsageByMonth.count
|
||||
|
||||
@@ -5,7 +5,11 @@ from sqlalchemy import asc, desc
|
||||
from sqlalchemy.sql.expression import bindparam
|
||||
|
||||
from app import db
|
||||
from app.models import (Template, TemplateHistory, TemplateRedacted)
|
||||
from app.models import (
|
||||
Template,
|
||||
TemplateHistory,
|
||||
TemplateRedacted
|
||||
)
|
||||
from app.dao.dao_utils import (
|
||||
transactional,
|
||||
version_class
|
||||
@@ -135,7 +139,7 @@ def dao_get_templates_for_cache(cache):
|
||||
query = db.session.query(Template.id.label('template_id'),
|
||||
Template.template_type,
|
||||
Template.name,
|
||||
Template.hidden,
|
||||
Template.is_precompiled_letter,
|
||||
cache_subq.c.count.label('count')
|
||||
).join(cache_subq,
|
||||
Template.id == cache_subq.c.template_id
|
||||
|
||||
Reference in New Issue
Block a user