Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/walterproof/dataset
Helper class to format a collection of rows into a tree
https://github.com/walterproof/dataset
Last synced: 7 days ago
JSON representation
Helper class to format a collection of rows into a tree
- Host: GitHub
- URL: https://github.com/walterproof/dataset
- Owner: WalterProof
- Created: 2017-07-19T08:40:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-01T20:30:22.000Z (over 7 years ago)
- Last Synced: 2024-07-06T13:56:18.764Z (4 months ago)
- Language: PHP
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
Dataset
=======This repository hosts a helper class to programmatically format an array of records into a tree structure.
Example:
From this set of records:
```
[
[
'aggregate1' => '2017-07-01',
'aggregate2' => 'foo',
'metric1' => 51,
'metric2' => 19,
'metric3' => 7,
],
[
'aggregate1' => '2017-07-01',
'aggregate2' => 'foo',
'metric1' => 33,
'metric2' => 13,
'metric3' => 37,
],
[
'aggregate1' => '2017-07-02',
'metric1' => 3,
'metric2' => 35,
'metric3' => 22,
],
]
```We should get this:
```
[
'2017-07-01' => [
'foo' => [
'metric1' => 84,
'metric2' => 32,
'metric3' => 44,
],
],
'2017-07-02' => [
'metric1' => 20
'metric2' => 29
'metric3' => 27
]
]
```Here the metrics are summed, but it should be allowed to provide an aggregate function
@todo tests with raw dumb data