I am working with an array retrieved from an Azure server Log (clicks array) that I need to sort in a specific way. Below is the request:
$http({
method: 'Get',
headers: {
'Host': 'api.applicationinsights.io',
'x-api-key': 'xxxxxxxxxxxxxx'
},
url: 'https://api.applicationinsights.io/v1/apps/20exxxx-xxxx-xxxx-xxxx-cf8bc569d261/query?query=requests | where timestamp > datetime(2018-03-13) and timestamp <= datetime(2018-03-22) %2B 1d | where name contains "GetCode" | where name contains "9278"'
})
.success(function (data) {
$scope.clicks = data.tables[0].rows;
console.log($scope.clicks)
})
The resulting array consists of approximately 275,000 rows:
0:
Array(37)
0:"2018-03-22T08:37:02.982Z"
1:"|ypdKJH+nmLI=.aeeeecd8_"
2:null
3:"GET /content/GetCode/192.0/9278"
etc.
1:
Array(37)
0:"2018-03-22T08:37:04.877Z"
1:"|nynZFXWHS7g=.aeeeece2_"
2:null
3:"GET /content/GetCode/1773.0/9278"
etc.
In my NG-Repeat, I only utilize [3], so I created the following:
<div ng-repeat="click in clicks">
click: {{(click[3].split('GET /content/GetCode/')[1]).split('/9278')[0]}}
</div>
This provides me with a list of values like:
192.0
1773.0
198.5
112,0
32.8
3148.7
etc. x 100.000
My aim now is to group these values into minute intervals, say every 30 seconds.
For example:
0- 30: 0
31- 60: 1 (aka 32.8)
61- 90: 0
91-120: 1 (aka 112.0)
121-150: 0
151-180: 0
181-210: 2 (aka 192.0 & 198.5)
211-240: 0 etc. etc. you get the idea i guess.
How can I achieve this grouping?