Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Handle when there are no dashboard for service_id
Browse files Browse the repository at this point in the history
This is tested by adding a data point to the fixture for which the
service_id matched no dashboard config in our test. As a result we
return an empty array. Without this code change an exception was thrown
as the list index was out of range.
  • Loading branch information
jcbashdown committed Jan 29, 2015
1 parent dee52a4 commit 6b9de05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def _service_ids_with_latest_data(data):

def _dashboard_configs_with_latest_data(data):
for service_id, latest_data in _service_ids_with_latest_data(data):
dashboard_config = admin_api.get_dashboard_by_tx_id(service_id)[0]
if dashboard_config:
yield dashboard_config, latest_data
dashboard_configs = admin_api.get_dashboard_by_tx_id(service_id)
if dashboard_configs:
yield dashboard_configs[0], latest_data


def _get_data_points_for_each_tx_metric(data, transform, data_set_config):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,25 @@
"service_id": "sorn-innit",
"total_cost": 6203480.9399999995,
"type": "seasonally-adjusted"
},
{
"_day_start_at": "2012-01-01T00:00:00+00:00",
"_hour_start_at": "2012-01-01T00:00:00+00:00",
"_id": "MjAxMi0wMS0wMSAwMDowMDowMDIwMTMtMDEtMDEgMDA6MDA6MDBiaXMtYW5udWFsLXJldHVybnM=",
"_month_start_at": "2012-01-01T00:00:00+00:00",
"_quarter_start_at": "2012-01-01T00:00:00+00:00",
"_timestamp": "2012-01-01T00:00:00+00:00",
"_updated_at": "2014-03-19T10:44:32.287000+00:00",
"_week_start_at": "2013-12-26T00:00:00+00:00",
"cost_per_transaction": 2.63,
"digital_cost_per_transaction": 2.36,
"digital_takeup": 0.9756123825537215,
"end_at": "2013-01-01T00:00:00+00:00",
"number_of_digital_transactions": 2301214,
"number_of_transactions": 2358738,
"period": "year",
"service_id": "something-without-a-dashboard",
"total_cost": 6203480.9399999995,
"type": "seasonally-adjusted"
}
]

0 comments on commit 6b9de05

Please sign in to comment.