Changeset 880


Ignore:
Timestamp:
05/18/13 18:25:10 (8 years ago)
Author:
ramonb
Message:

libtoga.php:

  • allow searchDbase query to include running jobs

templates/search.tpl:

  • added "include running jobs" checkbox

search.php:

  • pass include running option submit to searchDbase
  • some modifications to start/stop times for running jobs
  • closes #167
Location:
branches/1.0/web/addons/job_monarch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/web/addons/job_monarch/libtoga.php

    r874 r880  
    211211    }
    212212
    213     function searchDbase( $id = null, $queue = null, $owner = null, $name = null, $start_from_time = null, $start_to_time = null, $end_from_time = null, $end_to_time = null )
     213    function searchDbase( $id = null, $queue = null, $owner = null, $name = null, $start_from_time = null, $start_to_time = null, $end_from_time = null, $end_to_time = null, $include_running = false )
    214214    {
    215215        global $SEARCH_RESULT_LIMIT;
    216216
     217        if( $include_running )
     218        {
     219            $status_query = " AND job_status != 'Q'";
     220        }
     221        else
     222        {
     223            $status_query = " AND job_status = 'F'";
     224        }
     225
    217226        if( $id )
    218227        {
    219             $select_query = "SELECT job_id FROM jobs WHERE job_id = '$id' AND job_status = 'F'";
     228            $select_query = "SELECT job_id FROM jobs WHERE job_id = '$id'" . $status_query;
    220229            $this->resultcount = 1;
    221230        }
     
    253262            }
    254263
    255             $query = "FROM jobs WHERE job_status = 'F' AND ";
     264            $query = "FROM jobs WHERE ";
    256265            $extra_query_args = '';
    257266
     
    267276                }
    268277            }
    269             $query .= $extra_query_args;
     278            $query .= $extra_query_args . $status_query;
    270279
    271280            $count_result_idname = "COUNT(job_id)";
  • branches/1.0/web/addons/job_monarch/search.php

    r817 r880  
    226226    global $end_from_time, $end_to_time, $filter, $default_showhosts, $m, $hosts_up, $hc;
    227227    global $period_start, $period_stop, $sortby, $sortorder, $COLUMN_REQUESTED_MEMORY;
    228     global $SEARCH_RESULT_LIMIT, $COLUMN_NODES, $metricname, $self, $conf;
     228    global $SEARCH_RESULT_LIMIT, $COLUMN_NODES, $metricname, $self, $conf, $include_running;
     229
    229230
    230231    $longtitle = "Batch Archive Search :: Powered by Job Monarch!";
     
    236237    $tpl_data = new Dwoo_Data();
    237238
     239    if( in_array( $include_running, array('on','checked','true','yes') ) )
     240    {
     241        $include_running = true;
     242        $tpl_data->assign( "running_checked", "checked='on'" );
     243    }
    238244    $tpl_data->assign( "self", $self );
    239245    $tpl_data->assign( "cluster", $clustername );
     
    264270        if( $end_from_time ) $end_from_time = datetimeToEpoch( $end_from_time );
    265271        if( $end_to_time ) $end_to_time = datetimeToEpoch( $end_to_time );
    266         $search_ids = $tdb->searchDbase( $id, $queue, $owner, $name, $start_from_time, $start_to_time, $end_from_time, $end_to_time );
     272        $search_ids = $tdb->searchDbase( $id, $queue, $owner, $name, $start_from_time, $start_to_time, $end_from_time, $end_to_time, $include_running );
    267273
    268274        //print_r( $search_ids );
     
    354360            $job_start = $job['start_timestamp'];
    355361            $job_stop = $job['stop_timestamp'];
    356             $runningtime = intval( $job_stop - $job_start );
     362
     363            if( $job['status'] == 'R' )
     364            {
     365                $period_stop = time();
     366                $runningtime = $period_stop - intval( $job_start );
     367                $period_start = intval( $job_start - (intval( $runningtime * 0.10 ) ) );
     368                $node_list["finished"]= '';
     369            }
     370            else
     371            {
     372                $runningtime = intval( $job_stop - $job_start );
     373                $node_list["finished"]= makeDate( $job_stop );
     374            }
     375
    357376            $node_list["started"]= makeDate( $job_start );
    358             $node_list["finished"]= makeDate( $job_stop );
    359377            $node_list["runningtime"]= makeTime( $runningtime );
    360378           
     
    371389            $tpl_data->assign("checked$showhosts", "checked");
    372390
    373             if( $showhosts ) {
    374 
    375                 if( !$period_start ) // Add an extra 10% to graphstart
     391            if( $showhosts )
     392            {
     393                if( $job['status'] == 'R' )
     394                {
     395                    $period_stop = time();
     396                    $runningtime = $period_stop - intval( $job_start );
    376397                    $period_start = intval( $job_start - (intval( $runningtime * 0.10 ) ) );
     398                }
    377399                else
    378                     $period_start = datetimeToEpoch( $period_start );
    379 
    380                 if( !$period_stop ) // Add an extra 10% to graphend
    381                     $period_stop = intval( $job_stop + (intval( $runningtime * 0.10 ) ) );
    382                 else
    383                     $period_stop = datetimeToEpoch( $period_stop );
     400                {
     401                    if( !$period_start ) // Add an extra 10% to graphstart
     402                    {
     403                        $period_start = intval( $job_start - (intval( $runningtime * 0.10 ) ) );
     404                    }
     405                    else
     406                    {
     407                        $period_start = datetimeToEpoch( $period_start );
     408                    }
     409
     410                    if( !$period_stop ) // Add an extra 10% to graphend
     411                    {
     412                        $period_stop = intval( $job_stop + (intval( $runningtime * 0.10 ) ) );
     413                    }
     414                    else
     415                    {
     416                        $period_stop = datetimeToEpoch( $period_stop );
     417                    }
     418                }
     419
    384420
    385421                $tpl_data->assign( "timeperiod", "yes" );
  • branches/1.0/web/addons/job_monarch/templates/search.tpl

    r811 r880  
    187187  <TD></TD>
    188188  <TD></TD>
    189   <TD></TD>
     189  <TD><input type="checkbox" name="include_running" {$running_checked}>Include running jobs</TD>
    190190  <TD>
    191191  <INPUT TYPE="submit" VALUE="Search archive" onClick="setSearchTimestamps();">
Note: See TracChangeset for help on using the changeset viewer.