1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

fixed issues with metrics

This commit is contained in:
Damodar Lohani 2021-08-20 12:23:35 +05:45
parent 1d7daf9515
commit 7949d5b138

View file

@ -248,15 +248,19 @@ $cli
$projectId = $point['projectId'];
if (!empty($projectId) && $projectId != 'console') {
$dbForProject->setNamespace('project_' . $projectId . '_internal');
if($metric == 'functions.functionId.executions') {
var_dump($points);
}
$metricUpdated = $metric;
if (!empty($groupBy)) {
$groupedBy = $point[$groupBy] ?? '';
$groupedBy = $point[$options['groupBy']] ?? '';
if (empty($groupedBy)) {
continue;
}
$metric = str_replace($groupBy, $groupedBy, $metric);
$metricUpdated = str_replace($options['groupBy'], $groupedBy, $metric);
}
$time = \strtotime($point['time']);
$id = \md5($time . '_' . $period['key'] . '_' . $metric); //construct unique id for each metric using time, period and metric
$id = \md5($time . '_' . $period['key'] . '_' . $metricUpdated); //construct unique id for each metric using time, period and metric
$value = (!empty($point['value'])) ? $point['value'] : 0;
try {
$document = $dbForProject->getDocument('stats', $id);
@ -265,7 +269,7 @@ $cli
'$id' => $id,
'period' => $period['key'],
'time' => $time,
'metric' => $metric,
'metric' => $metricUpdated,
'value' => $value,
'type' => 0,
]));
@ -276,7 +280,7 @@ $cli
$latestTime[$metric][$period['key']] = $time;
} catch (\Exception$e) {
// if projects are deleted this might fail
Console::warning("Failed to save data for project {$projectId} and metric {$metric}");
Console::warning("Failed to save data for project {$projectId} and metric {$metricUpdated}");
}
}
}