mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
more
This commit is contained in:
@@ -102,7 +102,7 @@ def dao_get_provider_stats():
|
|||||||
current_datetime = utc_now()
|
current_datetime = utc_now()
|
||||||
first_day_of_the_month = current_datetime.date().replace(day=1)
|
first_day_of_the_month = current_datetime.date().replace(day=1)
|
||||||
|
|
||||||
subquery = (
|
subquerie = (
|
||||||
db.session.query(
|
db.session.query(
|
||||||
FactBilling.provider,
|
FactBilling.provider,
|
||||||
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier).label(
|
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier).label(
|
||||||
@@ -127,11 +127,11 @@ def dao_get_provider_stats():
|
|||||||
ProviderDetails.updated_at,
|
ProviderDetails.updated_at,
|
||||||
ProviderDetails.supports_international,
|
ProviderDetails.supports_international,
|
||||||
User.name.label("created_by_name"),
|
User.name.label("created_by_name"),
|
||||||
func.coalesce(subquery.c.current_month_billable_sms, 0).label(
|
func.coalesce(subquerie.c.current_month_billable_sms, 0).label(
|
||||||
"current_month_billable_sms"
|
"current_month_billable_sms"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.outerjoin(subquery, ProviderDetails.identifier == subquery.c.provider)
|
.outerjoin(subquerie, ProviderDetails.identifier == subquerie.c.provider)
|
||||||
.outerjoin(User, ProviderDetails.created_by_id == User.id)
|
.outerjoin(User, ProviderDetails.created_by_id == User.id)
|
||||||
.order_by(
|
.order_by(
|
||||||
ProviderDetails.notification_type,
|
ProviderDetails.notification_type,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from sqlalchemy import select
|
||||||
|
|
||||||
from app import create_uuid, db
|
from app import create_uuid, db
|
||||||
from app.dao.dao_utils import autocommit, version_class
|
from app.dao.dao_utils import autocommit, version_class
|
||||||
from app.models import ServiceInboundApi
|
from app.models import ServiceInboundApi
|
||||||
@@ -28,13 +30,23 @@ def reset_service_inbound_api(
|
|||||||
|
|
||||||
|
|
||||||
def get_service_inbound_api(service_inbound_api_id, service_id):
|
def get_service_inbound_api(service_inbound_api_id, service_id):
|
||||||
return ServiceInboundApi.query.filter_by(
|
return (
|
||||||
id=service_inbound_api_id, service_id=service_id
|
db.session.execute(
|
||||||
).first()
|
select(ServiceInboundApi).filter_by(
|
||||||
|
id=service_inbound_api_id, service_id=service_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.scalars()
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_service_inbound_api_for_service(service_id):
|
def get_service_inbound_api_for_service(service_id):
|
||||||
return ServiceInboundApi.query.filter_by(service_id=service_id).first()
|
return (
|
||||||
|
db.session.execute(select(ServiceInboundApi).filter_by(service_id=service_id))
|
||||||
|
.scalars()
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@autocommit
|
@autocommit
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ def dao_get_active_service_users(service_id):
|
|||||||
|
|
||||||
|
|
||||||
def dao_get_service_users_by_user_id(user_id):
|
def dao_get_service_users_by_user_id(user_id):
|
||||||
return ServiceUser.query.filter_by(user_id=user_id).all()
|
return (
|
||||||
|
db.session.execute(select(ServiceUser).filter_by(user_id=user_id))
|
||||||
|
.scalars()
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@autocommit
|
@autocommit
|
||||||
|
|||||||
Reference in New Issue
Block a user