Allow skipping the first 24 hours in relative release view
The first 24 hours of a release are extremely noisy, it's generally best to ignore it when comparing releases after a sufficient amount of time has passed.
This commit is contained in:
Родитель
8d7926e8ea
Коммит
a40a09c646
|
@ -58,12 +58,12 @@ Query parameters:
|
|||
* `platform` (required): Platform for measure (e.g. `windows`)
|
||||
* `measure` (required): Measure identifier (e.g. `main_crashes`)
|
||||
* `interval` (required): Interval of data to gather, in seconds
|
||||
* `start` (optional): Starting point to gather measure data from. If
|
||||
not specified, will return `interval` worth of data, counting back
|
||||
from the time of the query. This parameter is ignored if `relative`
|
||||
is specified (see below)
|
||||
* `relative` (optional): If true (specified and non-zero), return results
|
||||
*from* the time of release of the latest version
|
||||
* `start` (optional): Starting point to gather measure data from. If
|
||||
not specified, will return `interval` worth of data, counting either back
|
||||
from the time of the query (non-relative) or up to the specified time
|
||||
interval (relative).
|
||||
* `version` (optional): Retrieve only data particular to a specific version.
|
||||
May be specified multiple times.
|
||||
|
||||
|
|
|
@ -179,13 +179,17 @@ def measure(request):
|
|||
'version': version,
|
||||
'data': []
|
||||
}
|
||||
if start:
|
||||
start_timestamp = base_timestamp + datetime.timedelta(seconds=int(start))
|
||||
else:
|
||||
start_timestamp = base_timestamp
|
||||
ret[build_id]['data'] = [
|
||||
[int((timestamp - base_timestamp).total_seconds()), value, usage_hours] for
|
||||
(timestamp, value, usage_hours) in datums.filter(
|
||||
series__build__version=version,
|
||||
series__build__build_id=build_id,
|
||||
timestamp__range=(base_timestamp,
|
||||
base_timestamp + datetime.timedelta(seconds=int(interval)))
|
||||
timestamp__range=(start_timestamp,
|
||||
start_timestamp + datetime.timedelta(seconds=int(interval)))
|
||||
).order_by('timestamp').values_list('timestamp', 'value', 'usage_hours')]
|
||||
|
||||
return JsonResponse(data={'measure_data': ret})
|
||||
|
|
|
@ -207,24 +207,30 @@ def test_get_measure(fake_measure_data, client):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('interval', [86400, 300, 0])
|
||||
@pytest.mark.parametrize('start', [None, 0, 250, 301])
|
||||
@freeze_time('2017-07-01 13:00')
|
||||
def test_compare(fake_measure_data_offset, client, interval):
|
||||
def test_compare(fake_measure_data_offset, client, interval, start):
|
||||
(platform, channel, measure) = ('linux', 'release', 'main_crashes')
|
||||
|
||||
resp = client.get(reverse('measure'), {
|
||||
params = {
|
||||
'platform': platform,
|
||||
'channel': channel,
|
||||
'measure': measure,
|
||||
'interval': interval,
|
||||
'relative': 1
|
||||
})
|
||||
}
|
||||
if start is not None:
|
||||
params.update({'start': start})
|
||||
resp = client.get(reverse('measure'), params)
|
||||
# despite the samples being captured at different times, they should
|
||||
# return the same relative value for compare
|
||||
min_time = start or 0
|
||||
expected_data = [
|
||||
datum for datum in
|
||||
[[0, 100.0, 20.0],
|
||||
[300, 10.0, 16.0],
|
||||
[600, 10.0, 20.0]] if not interval or datum[0] <= interval
|
||||
[600, 10.0, 20.0]] if datum[0] >= min_time and
|
||||
(not interval or datum[0] <= (min_time + interval))
|
||||
]
|
||||
assert resp.json()['measure_data'] == {
|
||||
'20170620075044': {
|
||||
|
|
Загрузка…
Ссылка в новой задаче