From 0805cf87c3ab670ce20bec5252865d3debfd7b81 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 5 Oct 2014 02:17:03 -0700 Subject: [PATCH] admin web: in "result summary in last X", don't include delayed-file-delete jobs The config option lets you defer file deletion. If you set this, say, for 10 days, then the "results summary in last 24 hours" page will show jobs that finished 10 days ago and were file-deleted in the last day. This is generally not what you want. Change things so that in this case file-deleted results are treated as if their mod time were 10 days earlier. Note: this means that the counts of file-delete states won't be meaningful in this case. --- html/inc/db_ops.inc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/html/inc/db_ops.inc b/html/inc/db_ops.inc index 834329ee1a..dc478a5dc1 100644 --- a/html/inc/db_ops.inc +++ b/html/inc/db_ops.inc @@ -22,6 +22,7 @@ error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); +require_once("../inc/util_basic.inc"); require_once("../inc/result.inc"); class BoincAssignment { @@ -444,20 +445,30 @@ SELECT COUNT(id) AS nTotal, SUM(case when server_state = '5' and outcome = '3' and client_state = '4' then 1 else 0 end) AS clientstate_uploading, SUM(case when server_state = '5' and outcome = '3' and client_state = '5' then 1 else 0 end) AS clientstate_uploaded, SUM(case when server_state = '5' and outcome = '3' and client_state = '6' then 1 else 0 end) AS clientstate_aborted -FROM result WHERE +FROM result WHERE true "; if ($query_appid) { - $main_query .= "appid=$query_appid and "; + $main_query .= " and appid=$query_appid"; } if ($query_wuid) { - $main_query .= "workunitid=$query_wuid and "; + $main_query .= " and workunitid=$query_wuid"; } if ($query_mod_time) { - $main_query .= "mod_time > DATE_SUB( NOW(), INTERVAL $query_mod_time SECOND )+0 and "; - } + $start = time() - $query_mod_time; - $main_query .= "1=1"; + // If file deletion is delayed by X, + // subtract X from mod time of file-deleted results. + // Otherwise we'll show lots of irrelevant results + // + $delay = parse_config(get_config(), ""); + if ($delay) { + $start2 = $start - $delay*3600;; + $main_query .= " and ((file_delete_state>1 and mod_time>FROM_UNIXTIME($start2)) or (mod_time>FROM_UNIXTIME($start)))"; + } else { + $main_query .= " and mod_time > FROM_UNIXTIME($start)"; + } + } $urlquery = $q->urlquery; $result = _mysql_query($main_query);