Skip to content

Commit

Permalink
QA: Having to add back last_state which is used
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Jan 2, 2025
1 parent 0947967 commit 6edc4ae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
4 changes: 0 additions & 4 deletions lib/funct_shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,6 @@ function get_template_status($template_id) {
return $status;
}


function in_process($report_id, $status = 1) {
$now = date("Y-m-d H:i:s");

Expand All @@ -763,7 +762,6 @@ function in_process($report_id, $status = 1) {
array($status, $now, $report_id));;
}


function stat_process($report_id) {
$sql = "SELECT state FROM plugin_reportit_reports WHERE id=$report_id";
return db_fetch_cell($sql);
Expand Down Expand Up @@ -810,8 +808,6 @@ function config_date_format($no_time=true) {
return $dd;
}



/* ********************* New functions ********************************* */
function debug(&$value, $msg = '', $fmsg = '') {
if (!defined('REPORTIT_DEBUG')) {
Expand Down
15 changes: 8 additions & 7 deletions poller_reportit.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,20 @@ function run_report($report_id) {
$start = microtime(true);
$start_time = time();

$report = db_fetch_row_prepared("SELECT a.id, a.template_id, a.name
FROM plugin_reportit_reports AS a
INNER JOIN plugin_reportit_templates AS b
ON b.locked = ''
AND a.template_id = b.id
WHERE a.id = ?",
$report = db_fetch_row_prepared("SELECT report.*
FROM plugin_reportit_reports AS report
INNER JOIN plugin_reportit_templates AS template
ON template.locked = ''
AND report.template_id = template.id
WHERE report.id = ?",
array($report_id));

if (!cacti_sizeof($report)) {
print PHP_EOL . PHP_EOL . "ERROR: Invalid report ID !" . PHP_EOL;
display_help();
} else {
$start_time = time();

if (!get_template_status($report['template_id'])) {
$report_id = $report['id'];

Expand All @@ -183,7 +184,7 @@ function run_report($report_id) {
WHERE id = ?',
array(
date('Y-m-d H:i:s', $start_time),
$end-$start,
$end - $start,
$report_id
)
);
Expand Down
2 changes: 2 additions & 0 deletions system/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function reportit_recreate_cache_tables() {

/* status column */
$data['columns'][] = array('name' => 'state', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '0');
$data['columns'][] = array('name' => 'last_state', 'type' => 'timestamp', 'NULL' => true);

/* archive specific columns */
$data['columns'][] = array('name' => 'owner','type' => 'varchar(20)', 'NULL' => false, 'default' => '');
Expand Down Expand Up @@ -163,6 +164,7 @@ function reportit_system_install() {

/* status column */
$data['columns'][] = array('name' => 'state', 'type' => 'tinyint(1)', 'NULL' => false, 'default' => '0');
$data['columns'][] = array('name' => 'last_state', 'type' => 'timestamp', 'NULL' => true);

/* scheduling attributes */
$data['columns'][] = array('name' => 'sched_type', 'unsigned' => true, 'type' => 'int(10)', 'NULL' => false, 'default' => '0');
Expand Down
15 changes: 11 additions & 4 deletions system/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,12 @@ function reportit_system_upgrade($old_version) {
}

db_execute('ALTER TABLE plugin_reportit_reports DROP COLUMN enabled');
db_execute('ALTER TABLE plugin_reportit_reports DROP COLUMN state');
db_execute('ALTER TABLE plugin_reportit_reports ADD COLUMN enabled char(2) NOT NULL default "" AFTER name');
db_execute('ALTER TABLE plugin_reportit_reports ADD COLUMN state tinyint(3) unsigned NOT NULL default "0" AFTER enabled');

db_execute('ALTER TABLE plugin_reportit_reports DROP COLUMN state, DROP COLUMN last_state');
db_execute('ALTER TABLE plugin_reportit_reports
ADD COLUMN state tinyint(1) unsigned NOT NULL default "0" AFTER enabled,
ADD COLUMN last_state timestamp default NULL AFTER state');

foreach($reports as $r) {
switch($r['frequency']) {
Expand Down Expand Up @@ -507,12 +510,16 @@ function reportit_system_upgrade($old_version) {
} else {
db_execute('ALTER TABLE plugin_reportit_reports DROP COLUMN enabled');
db_execute('ALTER TABLE plugin_reportit_reports ADD COLUMN enabled char(2) NOT NULL default "" AFTER name');

db_execute('ALTER TABLE plugin_reportit_reports DROP COLUMN state, DROP COLUMN last_state');
db_execute('ALTER TABLE plugin_reportit_reports
ADD COLUMN state tinyint(1) unsigned NOT NULL default "0" AFTER enabled,
ADD COLUMN last_state timestamp default NULL AFTER state');
}

$drop_columns = array(
'frequency',
'last_run',
'last_state',
'runtime',
'autoexport',
'autoexport_max_records',
Expand All @@ -523,7 +530,7 @@ function reportit_system_upgrade($old_version) {
$alter = 'ALTER TABLE plugin_reportit_reports';
$alter = '';
foreach($drop_columns as $c) {
if (db_column_exists('plugin_reportit_reports', 'last_state')) {
if (db_column_exists('plugin_reportit_reports', $c)) {
$alter .= ($alter != '' ? ', ':'') . "DROP COLUMN `$c`";
}
}
Expand Down

0 comments on commit 6edc4ae

Please sign in to comment.