mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -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.sum(FactBilling.billable_units * FactBilling.rate_multiplier)
|
||||
).cast(Integer), 0).label('sms_remainder')
|
||||
).join(
|
||||
AnnualBilling, FactBilling.service_id == AnnualBilling.service_id,
|
||||
).filter(
|
||||
FactBilling.service_id == Service.id,
|
||||
FactBilling.service_id == AnnualBilling.service_id,
|
||||
FactBilling.bst_date >= start_of_year,
|
||||
FactBilling.bst_date < start_date,
|
||||
FactBilling.notification_type == SMS_TYPE,
|
||||
|
||||
Reference in New Issue
Block a user