mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-17 02:32:32 -05:00
clean up usage of dates/datetimes in performance platform tasks
* call variables unambiguous things like `start_time` or `bst_date` to reduce risk of passing in the wrong thing * simplify the count_dict object - remove nested dict and start_date fields as superfluous * use static datetime objects in tests rather than calculating them each time
This commit is contained in:
@@ -9,29 +9,29 @@ from app import performance_platform_client
|
||||
|
||||
def send_processing_time_to_performance_platform():
|
||||
today = datetime.utcnow()
|
||||
start_date = get_midnight_for_day_before(today)
|
||||
end_date = get_london_midnight_in_utc(today)
|
||||
start_time = get_midnight_for_day_before(today)
|
||||
end_time = get_london_midnight_in_utc(today)
|
||||
|
||||
send_processing_time_for_start_and_end(start_date, end_date)
|
||||
send_processing_time_for_start_and_end(start_time, end_time)
|
||||
|
||||
|
||||
def send_processing_time_for_start_and_end(start_date, end_date):
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(start_date, end_date)
|
||||
def send_processing_time_for_start_and_end(start_time, end_time):
|
||||
result = dao_get_total_notifications_sent_per_day_for_performance_platform(start_time, end_time)
|
||||
|
||||
current_app.logger.info(
|
||||
'Sending processing-time to performance platform for date {}. Total: {}, under 10 secs {}'.format(
|
||||
start_date, result.messages_total, result.messages_within_10_secs
|
||||
start_time, result.messages_total, result.messages_within_10_secs
|
||||
)
|
||||
)
|
||||
|
||||
send_processing_time_data(start_date, 'messages-total', result.messages_total)
|
||||
send_processing_time_data(start_date, 'messages-within-10-secs', result.messages_within_10_secs)
|
||||
send_processing_time_data(start_time, 'messages-total', result.messages_total)
|
||||
send_processing_time_data(start_time, 'messages-within-10-secs', result.messages_within_10_secs)
|
||||
|
||||
|
||||
def send_processing_time_data(date, status, count):
|
||||
def send_processing_time_data(start_time, status, count):
|
||||
payload = performance_platform_client.format_payload(
|
||||
dataset='processing-time',
|
||||
date=date,
|
||||
start_time=start_time,
|
||||
group_name='status',
|
||||
group_value=status,
|
||||
count=count
|
||||
|
||||
Reference in New Issue
Block a user