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

Commit

Permalink
Merge pull request #415 from alphagov/handle-multiple-dashboards-for-…
Browse files Browse the repository at this point in the history
…service-id

Handle multiple data points for a service id.
  • Loading branch information
timmow committed Jan 30, 2015
2 parents 65de900 + b57b6f3 commit 0058974
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,14 @@ def _service_ids_with_data(data):


def _get_dashboard_config(service_id):
dashboard_configs = admin_api.get_dashboard_by_tx_id(service_id)
if dashboard_configs:
return dashboard_configs[0]
else:
return None
return admin_api.get_dashboard_by_tx_id(service_id)


def _get_dashboard_configs_with_data(ids_with_data):
dashboard_configs_with_data = []
for service_id, data in ids_with_data:
dashboard_config = _get_dashboard_config(service_id)
if dashboard_config:
dashboard_configs = _get_dashboard_config(service_id)
for dashboard_config in dashboard_configs:
dashboard_configs_with_data.append((dashboard_config, data))
return dashboard_configs_with_data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@
"dashboard_slug": "quarterly-nonsense",
"type": "quarterly"
},
{
"_id": encode_id(
'quarterly-nonsense2',
'digital_cost_per_transaction'),
"_timestamp": "2012-12-12T00:00:00+00:00",
"digital_cost_per_transaction": 2.36,
"end_at": "2013-01-01T00:00:00+00:00",
"period": "year",
"service_id": "service-with-quarterly-data",
"dashboard_slug": "quarterly-nonsense2",
"type": "quarterly"
},
{
"_id": encode_id('quarterly-nonsense2', 'digital_takeup'),
"_timestamp": "2012-12-12T00:00:00+00:00",
"digital_takeup": 0.9756123825537215,
"end_at": "2013-01-01T00:00:00+00:00",
"period": "year",
"service_id": "service-with-quarterly-data",
"dashboard_slug": "quarterly-nonsense2",
"type": "quarterly"
},
{
"_id": encode_id('sorn', 'cost_per_transaction'),
"_timestamp": "2013-04-01T00:00:00+00:00",
Expand Down Expand Up @@ -166,9 +188,14 @@
'slug': 'bis-returns'
}]

quarterly_data_dashboard_config = [{
'slug': 'quarterly-nonsense'
}]
quarterly_data_dashboard_config = [
{
'slug': 'quarterly-nonsense'
},
{
'slug': 'quarterly-nonsense2'
}
]


class ComputeTestCase(unittest.TestCase):
Expand Down Expand Up @@ -197,7 +224,7 @@ def test_compute(self, mock_dashboard_finder, mock_dataset):
'data-group': 'transactions-explorer',
'data-type': 'spreadsheet'}})

assert_that(len(transformed_data), is_(13))
assert_that(len(transformed_data), is_(15))
assert_that(transformed_data, contains_inanyorder(*data_to_post))

@patch("performanceplatform.client.DataSet.from_group_and_type")
Expand Down

0 comments on commit 0058974

Please sign in to comment.