mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 06:52:06 -05:00
Add labels to query so that the named tuples can be referenced later.
Remove unnecessary function
This commit is contained in:
@@ -50,8 +50,8 @@ def _monthly_billing_data_to_json(monthly):
|
||||
# (month, billing_units, rate_multiplier, international, notification_type, rate)
|
||||
# total cost must take into account the free allowance.
|
||||
# might be a good idea to capture free allowance in this table
|
||||
return [{"billing_units": x[1],
|
||||
"rate_multiplier": x[2],
|
||||
"international": x[3],
|
||||
"rate": x[5],
|
||||
"total_cost": (x[1] * x[2]) * x[5]} for x in monthly]
|
||||
return [{"billing_units": x.billing_units,
|
||||
"rate_multiplier": x.rate_multiplier,
|
||||
"international": x.international,
|
||||
"rate": x.rate,
|
||||
"total_cost": (x.billing_units * x.rate_multiplier) * x.rate} for x in monthly]
|
||||
|
||||
@@ -142,12 +142,12 @@ def is_between(date, start_date, end_date):
|
||||
def sms_billing_data_per_month_query(rate, service_id, start_date, end_date):
|
||||
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
||||
result = db.session.query(
|
||||
month,
|
||||
func.sum(NotificationHistory.billable_units),
|
||||
rate_multiplier(),
|
||||
month.label('month'),
|
||||
func.sum(NotificationHistory.billable_units).label('billing_units'),
|
||||
rate_multiplier().label('rate_multiplier'),
|
||||
NotificationHistory.international,
|
||||
NotificationHistory.notification_type,
|
||||
cast(rate, Float())
|
||||
cast(rate, Float()).label('rate')
|
||||
).filter(
|
||||
*billing_data_filter(SMS_TYPE, start_date, end_date, service_id)
|
||||
).group_by(
|
||||
|
||||
@@ -9,8 +9,3 @@ def create_provider_rates(provider_identifier, valid_from, rate):
|
||||
|
||||
provider_rates = ProviderRates(provider_id=provider.id, valid_from=valid_from, rate=rate)
|
||||
db.session.add(provider_rates)
|
||||
|
||||
|
||||
@transactional
|
||||
def create_sms_rate(rate):
|
||||
db.session.add(rate)
|
||||
|
||||
Reference in New Issue
Block a user