Ignore:
Timestamp:
01/23/09 17:27:58 (16 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/MagicSoft/Mars/datacenter/db/runinfo-aio.php

    r9150 r9249  
    1717        $query0 = "SELECT ";
    1818
    19         if ($groups>0)
     19        if ($groups>0 || ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0) || $statusgroups>0)
    2020        {
    2121            foreach ($checkgroup as $key => $element)
    2222                if ($element==-1)
    2323                    $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
     24
     25            if ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0)
     26            {
     27                $query0 .= " DATE_FORMAT(ADDDATE(fRunStart,Interval 12 hour), '";
     28                switch($_GET["fGroupByDate"])
     29                {
     30                case "Year":
     31                    $query0 .= "%Y ";
     32                    break;
     33                case "Month":
     34                    $query0 .= "%Y-%m ";
     35                    break;
     36                case "Night":
     37                    $query0 .= "%Y-%m-%d ";
     38                    break;
     39                }
     40                $query0 .= "')  AS GroupByDate, ";
     41            }
     42
    2443            //--------------------------------------------------
    2544            //$query0 .= " TIMEDIFF(fRunStop, fRunStart), ";
     
    3352            $query0 .= " Max(fZenithDistance) as '" . $alias["Max(fZenithDistance)"] . "', ";
    3453            $query0 .= " COUNT(*) as '# Runs' ";
    35         }
    36         else
    37         {
     54
    3855            if ($statusgroups>0)
    3956            {
    4057                foreach ($checkstatusgroup as $key => $element)
    4158                    if ($element==-1)
    42                         $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 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] . "', ";
     59                        $query0 .= ", (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 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] . "' ";
    4360//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
    4461
    45                 $query0 .= " count(*) as '# Runs'";
     62                $query0 .= ", COUNT(*) AS '# Runs'";
    4663
    4764            }
    48             else
     65        }
     66        else
     67        {
     68            //$query0 .= " RunData.fRunNumber as 'Run#' ";
     69            //$query0 .= " Concat(RunData.fTelescopeNumber,':', RunData.fRunNumber,':', RunData.fFileNumber) as 'Run' ";
     70            $query0 .= " Concat('M', RunData.fTelescopeNumber,':', LPAD(RunData.fRunNumber,8, ' '),'/', LPAD(RunData.fFileNumber, 3, ' ')) as 'Tel:Run/File' ";
     71
     72            if (empty($_GET["fSendTxt"]) && !empty($_GET["fLinks"]))
    4973            {
    50 //                $query0 .= " RunData.fRunNumber as 'Run#' ";
    51 //                $query0 .= " Concat(RunData.fTelescopeNumber,':', RunData.fRunNumber,':', RunData.fFileNumber) as 'Run' ";
    52                 $query0 .= " Concat('M', RunData.fTelescopeNumber,':', LPAD(RunData.fRunNumber,8, ' '),'/', LPAD(RunData.fFileNumber, 3, ' ')) as 'Tel:Run/File' ";
    53 
    54                 if (empty($_GET["fSendTxt"]) && !empty($_GET["fLinks"]))
    55                 {
    56                     $query0 .= ", CONCAT('<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
    57                     $query0 .= " as 'Links'";
    58                 }
    59 
    60                 foreach ($_GET as $key => $element)
    61                     if ($key!="fLinks" && $_GET[$key]=="On" && $key!="fTest")
    62                         if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
    63                             $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
     74                $query0 .= ", CONCAT('<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
     75                $query0 .= " as 'Links'";
    6476            }
     77
     78            foreach ($_GET as $key => $element)
     79                if ($key!="fLinks" && $_GET[$key]=="On" && $key!="fTest")
     80                    if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
     81                        $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
    6582        }
    6683
     
    165182        }
    166183
     184        if ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0)
     185            if (strpos($query0, " GROUP BY ")==FALSE)
     186                $query0 .= " GROUP BY GroupByDate ";
     187            else
     188                $query0 .= ", GroupByDate ";
     189
    167190        if ($statusgroups>0)
    168191        {
    169             $query0 .= " GROUP BY ";
     192            if (strpos($query0, " GROUP BY ")==FALSE)
     193                $query0 .= " GROUP BY  ";
     194            else
     195                $query0 .= ",  ";
    170196            $num = $statusgroups;
    171197            foreach ($checkstatusgroup as $key => $element)
     
    264290        printf(" <P>\n");
    265291        PrintSourceMenu($host,$user,$pw,$db);
     292        PrintGroupByDateMenu();
    266293        printf("<p>");
    267294        printf("</div>");
Note: See TracChangeset for help on using the changeset viewer.