Latest and greatest.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-02-02 11:40:25 -05:00
parent 544bf35c06
commit 689ff10b71
6 changed files with 84 additions and 51 deletions

View File

@@ -146,7 +146,7 @@ def fetch_notification_status_for_service_for_today_and_7_previous_days(
stats_for_today = (
db.session.query(
Notification.notification_type.cast(db.Text),
Notification.notification_type,
Notification.status,
*([Notification.template_id] if by_template else []),
func.count().label("count"),
@@ -212,14 +212,14 @@ def fetch_notification_status_totals_for_all_services(start_date, end_date):
if start_date <= datetime.utcnow().date() <= end_date:
stats_for_today = (
db.session.query(
Notification.notification_type.cast(db.Text).label("notification_type"),
Notification.notification_type.label("notification_type"),
Notification.status,
Notification.key_type,
func.count().label("count"),
)
.filter(Notification.created_at >= today)
.group_by(
Notification.notification_type.cast(db.Text),
Notification.notification_type,
Notification.status,
Notification.key_type,
)
@@ -297,7 +297,7 @@ def fetch_stats_for_all_services_by_date_range(
today = get_midnight_in_utc(datetime.utcnow())
subquery = (
db.session.query(
Notification.notification_type.cast(db.Text).label("notification_type"),
Notification.notification_type.label("notification_type"),
Notification.status.label("status"),
Notification.service_id.label("service_id"),
func.count(Notification.id).label("count"),
@@ -450,7 +450,7 @@ def fetch_monthly_template_usage_for_service(start_date, end_date, service_id):
def get_total_notifications_for_date_range(start_date, end_date):
query = (
db.session.query(
FactNotificationStatus.local_date.cast(db.Text).label("local_date"),
FactNotificationStatus.local_date.label("local_date"),
func.sum(
case(
[

View File

@@ -1,5 +1,6 @@
from strenum import StrEnum # In 3.11 this is in the enum library. We will not need
# this external library any more.
from strenum import StrEnum # In 3.11 this is in the enum library. We will not need
# this external library any more.
class TemplateType(StrEnum):

View File

@@ -1973,10 +1973,7 @@ class Rate(db.Model):
notification_type = enum_column(NotificationType, index=True, nullable=False)
def __str__(self):
the_string = "{}".format(self.rate)
the_string += " {}".format(self.notification_type)
the_string += " {}".format(self.valid_from)
return the_string
return f"{self.rate} {self.notification_type} {self.valid_from}"
class InboundSms(db.Model):
@@ -2140,7 +2137,11 @@ class FactNotificationStatus(db.Model):
job_id = db.Column(UUID(as_uuid=True), primary_key=True, index=True, nullable=False)
notification_type = enum_column(NotificationType, primary_key=True, nullable=False)
key_type = enum_column(KeyType, primary_key=True, nullable=False)
notification_status = enum_column(NotificationStatus, primary_key=True, nullable=False)
notification_status = enum_column(
NotificationStatus,
primary_key=True,
nullable=False,
)
notification_count = db.Column(db.Integer(), nullable=False)
created_at = db.Column(
db.DateTime,