Changeset 9486 for trunk/MagicSoft/Mars/datacenter/db/ctamcinfo.php
- Timestamp:
- 08/11/09 16:28:36 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/db/ctamcinfo.php
r9474 r9486 17 17 $query0 = "SELECT "; 18 18 19 if ($groups>0) 20 { 21 foreach ($checkgroup as $key => $element) 22 if ($element==-1) 23 $query0 .= $key . " as '" . $alias[$key] . "' " . ", "; 24 /* 25 //-------------------------------------------------- 26 //$query0 .= " TIMEDIFF(fRunStop, fRunStart), "; 27 // Only available in MySQL>4.1.1 28 $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " . 29 "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " . 30 "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', "; 31 //-------------------------------------------------- 32 $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', "; 33 $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', "; 34 $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', "; 35 */ 36 $query0 .= " COUNT(*) as '# Runs' "; 37 } 38 else 39 { 19 if ($groups>0 || $statusgroups>0) 20 { 21 if ($groups>0) 22 { 23 foreach ($checkgroup as $key => $element) 24 if ($element==-1) 25 $query0 .= $key . " as '" . $alias[$key] . "' " . ", "; 26 /* 27 //-------------------------------------------------- 28 //$query0 .= " TIMEDIFF(fRunStop, fRunStart), "; 29 // Only available in MySQL>4.1.1 30 $query0 .= "SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0, " . 31 "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60, " . 32 "TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)))/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', "; 33 //-------------------------------------------------- 34 $query0 .= " SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "', "; 35 $query0 .= " Min(fZenithDistance) as '" . $alias["Min(fZenithDistance)"] . "', "; 36 $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', "; 37 */ 38 } 40 39 if ($statusgroups>0) 41 40 { … … 43 42 if ($element==-1) 44 43 $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval " . $timelimits[$key] . " hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', "; 45 // $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";46 47 $query0 .= " count(*) as '# Runs'";44 // $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', "; 45 46 // $query0 .= " count(*) as '# Runs'"; 48 47 49 48 } 50 else 51 { 52 $query0 .= " MCRunData.fMCRunNumber as 'Run#' "; 49 $query0 .= " COUNT(*) as '# Runs' "; 50 $query0 .= ", SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "' "; 51 $query0 .= ", SUM(fNumEvents) DIV 1000 as '" . $alias["SUM(fNumEvents) DIV 1000"] . "' "; 52 } 53 else 54 { 55 $query0 .= " MCRunData.fMCRunNumber as 'Run' "; 53 56 // $query0 .= " Concat(RunData.fTelescopeNumber,':', RunData.fRunNumber,':', RunData.fFileNumber) as 'Run' "; 54 57 // $query0 .= " Concat('M', RunData.fTelescopeNumber,':', LPAD(RunData.fRunNumber,8, ' '),'/', LPAD(RunData.fFileNumber, 3, ' ')) as 'Tel:Run/File' "; 55 58 56 if (empty($_GET["fSendTxt"]) && !empty($_GET["fLinks"])) 57 { 58 $query0 .= ", CONCAT('<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&fDate=2\">rbk</A>') "; 59 $query0 .= " as 'Links'"; 60 } 61 62 foreach ($_GET as $key => $element) 63 if ($key!="fLinks" && $_GET[$key]=="On" && $key!="fTest") 64 if (empty($checkwhere[$key]) || $checkwhere[$key]==0) 65 $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; 59 if (empty($_GET["fSendTxt"]) && !empty($_GET["fLinks"])) 60 { 61 $query0 .= ", CONCAT('<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&fDate=2\">rbk</A>') "; 62 $query0 .= " as 'Links'"; 66 63 } 64 65 foreach ($_GET as $key => $element) 66 if ($key!="fLinks" && $_GET[$key]=="On" && $key!="fTest") 67 if (empty($checkwhere[$key]) || $checkwhere[$key]==0) 68 $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; 67 69 } 68 70 … … 105 107 $query0 .= " AND "; 106 108 107 $query0 .= StatusQuery("fCorsikaSimTelarray", $needs );108 $query0 .= StatusQuery("fChimp", $needs );109 $query0 .= StatusQuery("fCTAStar", $needs );110 $query0 .= StatusQuery("fStereoB", $needs );111 $query0 .= StatusQuery("fStereoC", $needs );112 $query0 .= StatusQuery("fStereoG", $needs );109 $query0 .= StatusQuery("fCorsikaSimTelarray", $needs, $timelimits); 110 $query0 .= StatusQuery("fChimp", $needs, $timelimits); 111 $query0 .= StatusQuery("fCTAStar", $needs, $timelimits); 112 $query0 .= StatusQuery("fStereoB", $needs, $timelimits); 113 $query0 .= StatusQuery("fStereoC", $needs, $timelimits); 114 $query0 .= StatusQuery("fStereoG", $needs, $timelimits); 113 115 114 116 if ((!empty($_GET["fRunMin"]) || $_GET["fRunMin"]=="0") && !empty($_GET["fRunMax"])) … … 176 178 if ($statusgroups>0) 177 179 { 178 $query0 .= " GROUP BY "; 180 // $query0 .= " GROUP BY "; 181 if (strpos($query0, " GROUP BY ")==FALSE) 182 $query0 .= " GROUP BY "; 183 else 184 $query0 .= ", "; 179 185 $num = $statusgroups; 180 186 foreach ($checkstatusgroup as $key => $element)
Note:
See TracChangeset
for help on using the changeset viewer.