for metric in metrics aggregates if params period name custom and metr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
for metric in metrics['aggregates']:
if params['period']['name'] == 'custom' and metric['config'].get('aggregates_external', False):
external_service = ExternalServiceAPI()
response, code = external_service.call(metric['config']['name'], {
'app_id': app.app_id,
'os': params['os'],
'start': params['period']['start'].strftime('%Y%m%d%H') if params.get('period', None) else None,
'end': params['period']['end'].strftime('%Y%m%d%H') if params.get('period', None) else None
})
metric['value'] = response.get('data', {}).get('value', '')
first_row.append(metric['config']['label'])
second_row.append(metric['value'] if metric['value'] else '')