From 4f2dcdacb441ba3548d4bf733743ba33149d5cbb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 30 Mar 2017 13:04:16 -0400 Subject: [PATCH] update, remove styles and fix the sql for limiting monitors --- web/skins/classic/views/montagereview.php | 208 +++++++++++----------- 1 file changed, 102 insertions(+), 106 deletions(-) diff --git a/web/skins/classic/views/montagereview.php b/web/skins/classic/views/montagereview.php index fffea92b9..e8f6de499 100644 --- a/web/skins/classic/views/montagereview.php +++ b/web/skins/classic/views/montagereview.php @@ -95,34 +95,35 @@ // if ( !canView( 'Events' ) ) { - $view = "error"; + $view = 'error'; return; } require_once( 'includes/Monitor.php' ); +# FIXME THere is no way to select group at this time. if ( !empty($_REQUEST['group']) ) { $group = $_REQUEST['group']; - $row = dbFetchOne( 'select * from Groups where Id = ?', NULL, array($_REQUEST['group']) ); - $monitorsSql = "select * from Monitors where Function != 'None' and find_in_set( Id, '".$row['MonitorIds']."' ) "; + $row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($_REQUEST['group']) ); + $monitorsSql = "SELECT * FROM Monitors WHERE Function != 'None' AND find_in_set( Id, '".$row['MonitorIds']."' ) "; } else { - $monitorsSql = "select * from Monitors "; - $group = ""; + $monitorsSql = "SELECT * FROM Monitors WHERE 1>0"; + $group = ''; } // Note that this finds incomplete events as well, and any frame records written, but still cannot "see" to the end frame // if the bulk record has not been written - to be able to include more current frames reduce bulk frame sizes (event size can be large) // Note we round up just a bit on the end time as otherwise you get gaps, like 59.78 to 00 in the next second, which can give blank frames when moved through slowly. -$eventsSql = " - select E.Id,E.Name,E.StorageId,UNIX_TIMESTAMP(E.StartTime) as StartTimeSecs, - case when E.EndTime is null then (Select UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval max(Delta)+0.5 Second)) from Frames F where F.EventId=E.Id) - else UNIX_TIMESTAMP(E.EndTime) - end as CalcEndTimeSecs, E.Length, - case when E.Frames is null then (Select count(*) from Frames F where F.EventId=E.Id) else E.Frames end as Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId - from Events as E - inner join Monitors as M on (E.MonitorId = M.Id) - where not isnull(E.Frames) and not isnull(StartTime) "; +$eventsSql = ' + SELECT E.Id,E.Name,E.StorageId,UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs, + CASE WHEN E.EndTime IS NULL THEN (SELECT UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval max(Delta)+0.5 Second)) FROM Frames F WHERE F.EventId=E.Id) + ELSE UNIX_TIMESTAMP(E.EndTime) + END AS CalcEndTimeSecs, E.Length, + CASE WHEN E.Frames IS NULL THEN (Select count(*) FROM Frames F WHERE F.EventId=E.Id) ELSE E.Frames END AS Frames,E.MaxScore,E.Cause,E.Notes,E.Archived,E.MonitorId + FROM Events AS E + INNER JOIN Monitors AS M ON (E.MonitorId = M.Id) + WHERE NOT isnull(E.Frames) AND NOT isnull(StartTime)'; @@ -133,20 +134,19 @@ $eventsSql = " // where not isnull(E.Frames) and not isnull(StartTime) "; // Note that the delta value seems more accurate than the time stamp for some reason. -$frameSql = " - select E.Id as eId, E.MonitorId, UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval Delta Second)) as TimeStampSecs, max(F.Score) as Score - from Events as E - inner join Frames as F on (F.EventId = E.Id) - where not isnull(StartTime) and F.Score>0 "; +$frameSql = ' + SELECT E.Id AS eId, E.MonitorId, UNIX_TIMESTAMP(DATE_ADD(E.StartTime, Interval Delta Second)) AS TimeStampSecs, max(F.Score) AS Score + FROM Events AS E + INNER JOIN Frames AS F ON (F.EventId = E.Id) + WHERE NOT isnull(StartTime) AND F.Score>0'; // This program only calls itself with the time range involved -- it does all monitors (the user can see, in the called group) all the time -if ( !empty($user['MonitorIds']) ) -{ +if ( ! empty( $user['MonitorIds'] ) ) { $monFilterSql = ' AND M.Id IN ('.$user['MonitorIds'].')'; $eventsSql .= $monFilterSql; - $monitorsSQL .= $monFilterSql; + $monitorsSql .= ' AND Id IN ('.$user['MonitorIds'].')'; $frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')'; } @@ -156,87 +156,82 @@ if ( !empty($user['MonitorIds']) ) // The default (nothing at all specified) is for 1 hour so we do not read the whole database -if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) -{ - $maxTime=strftime("%c",time()); - $minTime=strftime("%c",time() - 3600); +if ( !isset($_REQUEST['minTime']) && !isset($_REQUEST['maxTime']) ) { + $maxTime = strftime("%c",time()); + $minTime = strftime("%c",time() - 3600); } if ( isset($_REQUEST['minTime']) ) - $minTime = validHtmlStr($_REQUEST['minTime']); + $minTime = validHtmlStr($_REQUEST['minTime']); if ( isset($_REQUEST['maxTime']) ) - $maxTime = validHtmlStr($_REQUEST['maxTime']); + $maxTime = validHtmlStr($_REQUEST['maxTime']); // AS a special case a "all" is passed in as an exterme interval - if so , clear them here and let the database query find them -if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) // test years -{ - $minTime=null; - $maxTime=null; +if ( (strtotime($maxTime) - strtotime($minTime))/(365*24*3600) > 30 ) { + // test years + $minTime = null; + $maxTime = null; } $fitMode=1; if (isset($_REQUEST['fit']) && $_REQUEST['fit']=='0' ) - $fitMode=0; + $fitMode = 0; if ( isset($_REQUEST['scale']) ) - $defaultScale=validHtmlStr($_REQUEST['scale']); + $defaultScale = validHtmlStr($_REQUEST['scale']); else - $defaultScale=1; + $defaultScale = 1; $speeds=[0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2, 3, 5, 10, 20, 50]; if (isset($_REQUEST['speed']) ) - $defaultSpeed=validHtmlStr($_REQUEST['speed']); + $defaultSpeed = validHtmlStr($_REQUEST['speed']); else - $defaultSpeed=1; + $defaultSpeed = 1; $speedIndex=5; // default to 1x -for ($i=0; $i