Skip to content

Commit

Permalink
More fixes for #5555
Browse files Browse the repository at this point in the history
The Task Item ID was missing to be able to differentiate between types.
  • Loading branch information
TheWitness committed Nov 20, 2023
1 parent bb46052 commit 3947bd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 11 additions & 7 deletions lib/api_aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1447,9 +1447,10 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
}

db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, 1, ?, '', ?, 2, ?)", array(
(local_graph_id, task_item_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, ?, 1, ?, '', ?, 2, ?)", array(
$local_graph_id,
$item['task_item_id'],
GRAPH_ITEM_TYPE_COMMENT,
$item['text_format'],
$item['hard_return'],
Expand All @@ -1474,11 +1475,11 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
if ($_total_type == AGGREGATE_TOTAL_TYPE_ALL) {
// All so use sum functions
$pparts[3] = str_replace('current', 'aggregate_sum', $pparts[3]);
$pparts[3] = str_replace('max', 'aggregate_sum', $pparts[3]);
$pparts[3] = str_replace('max', 'aggregate_sum_peak', $pparts[3]);
} else {
// Similar to separate
$pparts[3] = str_replace('current', 'aggregate', $pparts[3]);
$pparts[3] = str_replace('max', 'aggregate_peak', $pparts[3]);
$pparts[3] = str_replace('current', 'aggregate_current', $pparts[3]);
$pparts[3] = str_replace('max', 'aggregate_current_peak', $pparts[3]);
}

switch($pparts[3]) {
Expand Down Expand Up @@ -1506,7 +1507,9 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
break;
case 'aggregate_peak':
case 'aggregate_sum':
case 'aggregate_sum_peak':
case 'aggregate_current':
case 'aggregate_current_peak':
case 'aggregate':
$new_ppart = $pparts[3];

Expand All @@ -1528,9 +1531,10 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
}

db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, graph_type_id, color_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, ?, 1, ?, ?, '', 2, ?)", array(
(local_graph_id, task_item_id, graph_type_id, color_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, ?, ?, 1, ?, ?, '', 2, ?)", array(
$local_graph_id,
$item['task_item_id'],
GRAPH_ITEM_TYPE_HRULE,
$item['color_id'],
$item['text_format'],
Expand Down
6 changes: 5 additions & 1 deletion lib/graph_variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
if ($percentile < 1 || $percentile > 99) {
return -1;
}
cacti_log(implode(', ', array_values($graph_item)));

if (empty($graph_item['local_data_id'])) {
$graph_item['local_data_id'] = 0;
Expand All @@ -495,6 +496,7 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
$local_data_array[$local_data_id][] = $data_source_name;
}
}
cacti_log(" $type should be here");

/* Get the Nth percentile values */
if (!cacti_sizeof($nth_cache)) {
Expand Down Expand Up @@ -544,7 +546,7 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
case 'aggregate_current_peak':
$local_data_array = array();

if (!empty($graph_item['data_source_name'])) {
if ($graph_item['data_source_name'] != '') {
foreach ($graph_items as $graph_element) {
if ($graph_item['data_source_name'] == $graph_element['data_source_name'] &&
!empty($graph_element['data_template_rrd_id']) &&
Expand Down Expand Up @@ -584,6 +586,7 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
case 'total': // Total of the current data source name
case 'total_peak':
case 'aggregate_sum':
case 'aggregate_sum_peak':
if (!empty($nth_cache['nth_percentile_sum'])) {
$nth = $nth_cache['nth_percentile_sum'];
$nth = ($bytebit == 'bits') ? $nth * 8 : $nth;
Expand All @@ -595,6 +598,7 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
case 'all_max_peak':
case 'aggregate_max':
case 'aggregate_peak':
case 'aggregate_current_peak':
case 'max':
if (!empty($nth_cache['nth_percentile_maximum'])) {
$nth = $nth_cache['nth_percentile_maximum'];
Expand Down

0 comments on commit 3947bd5

Please sign in to comment.