mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
explicitly join annual_billing and remove reference to service.id
service.id isn't used in this query (both tables already have service_id), and explicitly joining makes what we're doing more obvious
This commit is contained in:
@@ -42,9 +42,9 @@ def fetch_sms_free_allowance_remainder(start_date):
|
|||||||
func.greatest((AnnualBilling.free_sms_fragment_limit -
|
func.greatest((AnnualBilling.free_sms_fragment_limit -
|
||||||
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier)
|
func.sum(FactBilling.billable_units * FactBilling.rate_multiplier)
|
||||||
).cast(Integer), 0).label('sms_remainder')
|
).cast(Integer), 0).label('sms_remainder')
|
||||||
|
).join(
|
||||||
|
AnnualBilling, FactBilling.service_id == AnnualBilling.service_id,
|
||||||
).filter(
|
).filter(
|
||||||
FactBilling.service_id == Service.id,
|
|
||||||
FactBilling.service_id == AnnualBilling.service_id,
|
|
||||||
FactBilling.bst_date >= start_of_year,
|
FactBilling.bst_date >= start_of_year,
|
||||||
FactBilling.bst_date < start_date,
|
FactBilling.bst_date < start_date,
|
||||||
FactBilling.notification_type == SMS_TYPE,
|
FactBilling.notification_type == SMS_TYPE,
|
||||||
|
|||||||
Reference in New Issue
Block a user