Skip to content

Commit

Permalink
QA: Final fix to #5555 - Aggregate Graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Nov 23, 2023
1 parent f1c1511 commit 398e58d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/api_aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,8 @@ function aggregate_create_update(&$local_graph_id, $member_graphs, $attribs) {
}

function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_graph_id, $_total, $_total_type) {
static $special_comments = null;
static $special_hrules = null;
$special_comments = null;
$special_hrules = null;

$agg_info = db_fetch_row_prepared('SELECT *
FROM aggregate_graphs
Expand All @@ -1333,6 +1333,8 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
AND (text_format != "" || value != "")
ORDER BY sequence ASC',
array(GRAPH_ITEM_TYPE_COMMENT, GRAPH_ITEM_TYPE_HRULE, $agg_info['graph_template_id']));

$graph_template_id = $agg_info['graph_template_id'];
} else {
if (cacti_sizeof($member_graphs)) {
$template_graph[] = $member_graphs[0];
Expand All @@ -1347,6 +1349,10 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
(cacti_sizeof($skipped_items) ? ' AND local_graph_id NOT IN(' . implode(',', $skipped_items) . ')':'') . '
AND (text_format != "" || value != "")
ORDER BY local_graph_id, sequence ASC');

if (cacti_sizeof($comments_hrules)) {
$graph_template_id = $comments_hrules[0]['graph_template_id'];
}
}

$next_item_sequence = db_fetch_cell_prepared('SELECT MAX(sequence)
Expand Down Expand Up @@ -1414,8 +1420,9 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
}

db_execute_prepared("INSERT INTO graph_templates_item
(local_graph_id, task_item_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, ?, 1, ?, '', ?, 2, ?)", array(
(graph_template_id, local_graph_id, task_item_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, ?, ?, 1, ?, '', ?, 2, ?)", array(
$graph_template_id,
$local_graph_id,
$item['task_item_id'],
GRAPH_ITEM_TYPE_COMMENT,
Expand Down Expand Up @@ -1486,13 +1493,14 @@ function aggregate_handle_ptile_type($member_graphs, $skipped_items, $local_grap
// add an empty line before nth percentile for the first item only
if (cacti_sizeof($special_hrules) == 1) {
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, 1, '', '', 'on', 2, ?)", array($local_graph_id, $next_item_sequence++));
(graph_template_id, local_graph_id, graph_type_id, consolidation_function_id, text_format, value, hard_return, gprint_id, sequence)
VALUES (?, ?, 1, 1, '', '', 'on', 2, ?)", array($graph_template_id, $local_graph_id, $next_item_sequence++));
}

db_execute_prepared("INSERT INTO graph_templates_item
(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(
(graph_template_id, 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(
$graph_template_id,
$local_graph_id,
$item['task_item_id'],
GRAPH_ITEM_TYPE_HRULE,
Expand Down

0 comments on commit 398e58d

Please sign in to comment.