alphagov/spotlight — pull request #835 by roc (2014-10-31 15:49:48+00:00)
Title: Regroup flat data responses

This is essentially a **shim** that will convert flattened data into grouped data, ready to be re-flattened.

The backdrop response that comes back 'flat' is not the same as spotlight's understanding of 'flat' so this is a temporary fix before we refactor data parsing in a more wholesale way in spotlight, once we're certain about the way it comes back from backdrop

- Group flat data by a key using `groupByValue`
- takes a value and an array of collects
- rebuilds grouped objects ready to be pushed through the remaining parsing methods
- adds `getCollect` convenience method to `data_source.js`

Parse groups with more than one record correctly

- Move to using groupByValue function rather than flatten
- needs some looking at aggregations that are not sums