mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Change the updates to only look at today, and not yesterday.
This commit is contained in:
@@ -244,11 +244,9 @@ def fetch_monthly_billing_for_year(service_id, year):
|
||||
today = convert_utc_to_bst(datetime.utcnow()).date()
|
||||
# if year end date is less than today, we are calculating for data in the past and have no need for deltas.
|
||||
if year_end_date >= today:
|
||||
yesterday = today - timedelta(days=1)
|
||||
for day in [yesterday, today]:
|
||||
data = fetch_billing_data_for_day(process_day=day, service_id=service_id, check_permissions=True)
|
||||
for d in data:
|
||||
update_fact_billing(data=d, process_day=day)
|
||||
data = fetch_billing_data_for_day(process_day=today, service_id=service_id, check_permissions=True)
|
||||
for d in data:
|
||||
update_fact_billing(data=d, process_day=today)
|
||||
|
||||
email_and_letters = db.session.query(
|
||||
func.date_trunc('month', FactBilling.bst_date).cast(Date).label("month"),
|
||||
@@ -648,12 +646,10 @@ def fetch_usage_year_for_organisation(organisation_id, year):
|
||||
services = dao_get_organisation_live_services(organisation_id)
|
||||
# if year end date is less than today, we are calculating for data in the past and have no need for deltas.
|
||||
if year_end_date >= today:
|
||||
yesterday = today - timedelta(days=1)
|
||||
for service in services:
|
||||
for day in [yesterday, today]:
|
||||
data = fetch_billing_data_for_day(process_day=day, service_id=service.id)
|
||||
for d in data:
|
||||
update_fact_billing(data=d, process_day=day)
|
||||
data = fetch_billing_data_for_day(process_day=today, service_id=service.id)
|
||||
for d in data:
|
||||
update_fact_billing(data=d, process_day=today)
|
||||
service_with_usage = {}
|
||||
# initialise results
|
||||
for service in services:
|
||||
|
||||
@@ -130,7 +130,7 @@ def get_organisation_services(organisation_id):
|
||||
@organisation_blueprint.route('/<uuid:organisation_id>/services-with-usage', methods=['GET'])
|
||||
def get_organisation_services_usage(organisation_id):
|
||||
try:
|
||||
year = int(request.args.get('year'))
|
||||
year = int(request.args.get('year', 'none'))
|
||||
except ValueError:
|
||||
return jsonify(result='error', message='No valid year provided'), 400
|
||||
services = fetch_usage_year_for_organisation(organisation_id, year)
|
||||
|
||||
Reference in New Issue
Block a user