ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/moderator/trendlineCorrectionReports.pl view on Meta::CPAN
if ($action eq 'listView') {
$htmlTitle = "Trendline Correction Reports";
my ($rv, $dbh, $sth, $sql);
$rv = 1;
# open connection to database and query data
$dbh = DBI->connect("DBI:mysql:$DATABASE:$SERVERNAMEREADONLY:$SERVERPORTREADONLY", "$SERVERUSERREADONLY", "$SERVERPASSREADONLY" ) or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subTitle...
if ( $dbh and $rv ) {
my $startDateEpoch = get_epoch ('-14 days');
my $startDate = sprintf ( "%04d-%02d-%02d", (localtime($startDateEpoch))[5]+1900, (localtime($startDateEpoch))[4]+1, (localtime($startDateEpoch))[3] );
my $yesterdayEpoch = get_epoch ('yesterday');
my $yesterday = sprintf ( "%04d-%02d-%02d", (localtime($yesterdayEpoch))[5]+1900, (localtime($yesterdayEpoch))[4]+1, (localtime($yesterdayEpoch))[3] );
my $actionPressend = ($iconDetails or $iconEdit) ? 1 : 0;
my $actionHeader = ($actionPressend) ? "<th>Action</th>" : '';
my $colspan = 10 + $actionPressend;
my $header = "<tr><th> Catalog ID </th><th> Title </th><th> uKey </th><th> Trendline </th><th> - </th><th> Average </th><th> % </th><th> + </th><th> % </th><th> Proposal </th>$actionHeader</tr>\n";
my $hostname = '';
(undef, undef, $hostname, undef) = split ( /\//, $ENV{HTTP_REFERER} ) if ( $ENV{HTTP_REFERER} );
$sql = "select catalogID, catalogName from $SERVERTABLCATALOG where not catalogID = '$CATALOGID' and activated = '1' order by catalogName asc";
($rv, $catalogIDSelect, undef) = create_combobox_from_DBI ($rv, $dbh, $sql, 1, '', $CcatalogID, 'catalogID', $CATALOGID, '-Parent-', '', 'onChange="javascript:submitForm();"', $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
my ($catalogID, $uKey, $title, $test, $resultsdir, $trendline, $percentage, $tolerance, $hour, $calculated);
$sql = "select SQL_NO_CACHE $SERVERTABLPLUGINS.catalogID, $SERVERTABLPLUGINS.uKey, concat( LTRIM(SUBSTRING_INDEX($SERVERTABLPLUGINS.title, ']', -1)), ' (', $SERVERTABLENVIRONMENT.label, ')' ) as Title, $SERVERTABLPLUGINS.test, $SERVERTABLPLUGIN...
$sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$catalogID, \$uKey, \$title, \$test, \$resultsdir, \$trendline, \$percentage, \$tolerance, \$hour, \$calculated ) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $s...
$matchingTrendlineCorrections .= '<table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="'. $COLORSTABLE{TABLE} .'"><tr><th align="center" colspan="'. $colspan .'"> Trendline > 0 </th></tr>'. $header;
if ( $rv ) {
sub matchingTrendlineCorrections {
my ($catalogID, $uKey, $title, $test, $resultsdir, $trendline, $percentage, $tolerance, $calculated) = @_;
use POSIX qw(ceil floor);
my ($calculatedMIN, $calculatedMAX, $calculatedNEW, $ActionItem);
$calculated = sprintf("%.2f", $calculated * ( 100 + $percentage ) / 100 );
if ( $tolerance ) {
$calculatedMIN = sprintf("%.2f", $calculated * ( 100 - $tolerance ) / 100 );
$calculatedMAX = sprintf("%.2f", $calculated * ( 100 + $tolerance ) / 100 );
$calculatedNEW = $trendline >= $calculatedMIN && $trendline <= $calculatedMAX ? 0 : ( $calculatedMAX > $trendline ? ceil( $calculatedMAX ) : ( floor( ($calculatedMAX + $trendline) / 2 ) < $calculatedMAX ? ceil( ($calculatedMAX + $trendlin...
$calculatedNEW = '' if ( $calculatedNEW == 0 or $calculatedNEW == $trendline );
} else {
$calculatedMIN = $calculatedMAX = $calculatedNEW = '';
}
$ActionItem = ( $actionPressend and $calculatedNEW ) ? 1 : '';
if ( $ActionItem or ! $shortlist ) {
$test =~ s/\.pl//g;
my $catalogID_uKey = ( ( $catalogID eq 'CID' ) ? '' : $catalogID .'_' ) . $uKey;
$ActionItem = " ";
$ActionItem .= "<A HREF=\"#\" onclick=\"openPngImage('/results/$resultsdir/$test-$catalogID_uKey-sql.html',912,576,null,null,'Trendline',10,false,'Trendline');\"><img src=\"$IMAGESURL/$ICONSRECORD{table}\" title=\"Trendline MRTG Chart\" a...
$ActionItem .= "<A HREF=\"#\" onclick=\"openPngImage('$HTTPSURL/cgi-bin/generateChart.pl?$urlAccessParameters&detailed=on&catalogID=$CcatalogID&uKey1=$uKey&uKey2=none&uKey3=none&startDate=$startDate&endDate=$yesterday&inputType=fromto&cha...
my $actionSkip = ( ( $catalogID eq $CATALOGID ) ? 0 : 1 );
unless ( $actionSkip ) {
if ( $userType >= 2 ) {
$ActionItem .= " <A HREF=\"#\" onclick=\"openPngImage('$HTTPSURL/cgi-bin/". ( ( $userType == 2 ) ? 'moderator' : 'admin' ) ."/plugins.pl?$urlAccessParameters&action=editView&catalogID=$CcatalogID&uKey=$uKey&orderBy=uKey',1016,760...
if ( $calculatedNEW ) {
$ActionItem .= "<A HREF=\"#\">";
$ActionItem .= ( $calculatedNEW > $trendline ? "<IMG SRC=\"$IMAGESURL/$ICONSRECORD{up}\" title=\"Update Trendline\" ALT=\"Update Trendline\" BORDER=0>" : "<IMG SRC=\"$IMAGESURL/$ICONSRECORD{down}\" title=\"Update Trendline\" ALT=\"U...
$ActionItem .= "<img src=\"$IMAGESURL/$ICONSRECORD{query}\" title=\"Update Trendline\" alt=\"Update Trendline\" border=\"0\">" if ( $userType >= 4 );
$ActionItem .= "</A> " if ( $userType >= 4 );
}
}
}
$matchingTrendlineCorrections .= "<tr bgcolor=\"$COLORSTABLE{STARTBLOCK}\"><td>$catalogID</td><td>$title</td><td>$uKey</td><td align=\"right\" bgcolor=\"#0F0F0F\"> $trendline </td><td align=\"right\" bgcolor=\"#335566\"> $c...
}
}
my ($groupEND, $groupMAX, $catalogIDPREV, $uKeyPREV, $titlePREV, $testPREV, $resultsdirPREV, $trendlinePREV, $percentagePREV, $tolerancePREV) = (0, 0, 0, 0, 0, 25, 5);
if ( $sth->rows ) {
while( $sth->fetch() ) {
$groupEND = ( $uKeyPREV ne '0' and $uKeyPREV ne $uKey ) ? 1 : 0;
if ( $groupEND ) {
matchingTrendlineCorrections ($catalogIDPREV, $uKeyPREV, $titlePREV, $testPREV, $resultsdirPREV, $trendlinePREV, $percentagePREV, $tolerancePREV, $groupMAX);
$groupMAX = $calculated;
} else {
$groupMAX = $calculated > $groupMAX ? $calculated : $groupMAX;
}
$catalogIDPREV = $catalogID;
$uKeyPREV = $uKey;
$titlePREV = $title;
$testPREV = $test;
$resultsdirPREV = $resultsdir;
$trendlinePREV = $trendline;
$percentagePREV = $percentage;
$tolerancePREV = $tolerance;
}
matchingTrendlineCorrections ($catalogIDPREV, $uKeyPREV, $titlePREV, $testPREV, $resultsdirPREV, $trendlinePREV, $percentagePREV, $tolerancePREV, $groupMAX);
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
unless ( $shortlist ) {
$sql = "select $SERVERTABLPLUGINS.catalogID, $SERVERTABLPLUGINS.uKey, concat( LTRIM(SUBSTRING_INDEX($SERVERTABLPLUGINS.title, ']', -1)), ' (', $SERVERTABLENVIRONMENT.label, ')' ) as Title, $SERVERTABLPLUGINS.test, $SERVERTABLPLUGINS.resultsdi...
$sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
$sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;
$sth->bind_columns( \$catalogID, \$uKey, \$title, \$test, \$resultsdir, \$trendline, \$percentage, \$tolerance, \$calculated ) or $rv = error_trap_DBI(*STDOUT, "Cannot sth->bind_columns: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitl...
$matchingTrendlineCorrections .= '<tr><td '. $colspan .'"> </th></tr><tr><th align="center" colspan="'. $colspan .'"> Trendline = 0 </th></tr>'. $header;
if ( $rv ) {
if ( $sth->rows ) {
while( $sth->fetch() ) {
matchingTrendlineCorrections ($catalogID, $uKey, $title, $test, $resultsdir, $trendline, $percentage, $tolerance, $calculated);
}
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
( run in 1.204 second using v1.01-cache-2.11-cpan-39bf76dae61 )