Changeset 248


Ignore:
Timestamp:
04/11/06 15:07:28 (15 years ago)
Author:
bastiaans
Message:

web/addons/job_monarch/conf.php:

  • added SEARCH_RESULT_LIMIT option to prevent HUGE result lists

web/addons/job_monarch/libtoga.php:

  • added a resultcount
  • changed sql query to count first and limit the results

web/addons/job_monarch/search.php:

  • added extra message when results are limited
Location:
trunk/web/addons/job_monarch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/conf.php

    r246 r248  
    33//
    44$default_showhosts = 1;
     5
     6// Stop displaying archive search results after SEARCH_RESULT_LIMIT
     7//
     8$SEARCH_RESULT_LIMIT = 20;
    59
    610// Show the column job attribute 'requested memory'?
  • trunk/web/addons/job_monarch/libtoga.php

    r246 r248  
    142142        function searchDbase( $id = null, $queue = null, $user = null, $name = null, $start_from_time = null, $start_to_time = null, $end_from_time = null, $end_to_time = null ) {
    143143
     144                global $SEARCH_RESULT_LIMIT;
     145
    144146                if( $id )
    145147                        $query = "SELECT job_id FROM jobs WHERE job_id = '$id' AND job_status = 'F'";
     
    162164                                $query_args[] = "job_stop_timestamp <= $end_to_time";
    163165
    164                         $query = "SELECT job_id FROM jobs WHERE job_status = 'F' AND ";
     166                        $query = "FROM jobs WHERE job_status = 'F' AND ";
    165167                        $extra_query_args = '';
    166168
     
    175177                }
    176178
    177                 $ids = $this->queryDbase( $query );
     179                $count_result_idname = "COUNT(job_id)";
     180                $select_result_idname = "job_id";
     181
     182                $count_query = "SELECT " . $count_result_idname . " " . $query;
     183
     184                $count_result = $this->queryDbase( $count_query );
     185                $this->resultcount = (int) $count_result[0][count];
     186
     187                $select_query = "SELECT " . $select_result_idname . " " . $query . " ORDER BY job_id LIMIT " . $SEARCH_RESULT_LIMIT;
     188                $ids = $this->queryDbase( $select_query );
    178189
    179190                $ret = array();
  • trunk/web/addons/job_monarch/search.php

    r247 r248  
    325325        global $end_from_time, $end_to_time, $filter, $default_showhosts, $m, $hosts_up;
    326326        global $period_start, $period_stop, $sortby, $sortorder, $COLUMN_REQUESTED_MEMORY;
     327        global $SEARCH_RESULT_LIMIT;
    327328
    328329        $metricname = $m;
     
    351352                if( $end_to_time ) $end_to_time = datetimeToEpoch( $end_to_time );
    352353                $search_ids = $tdb->searchDbase( $id, $queue, $user, $name, $start_from_time, $start_to_time, $end_from_time, $end_to_time );
     354
     355                if( ($tdb->resultcount) > (int) $SEARCH_RESULT_LIMIT ) {
     356                        $tpl->gotoBlock( "_ROOT" );
     357               
     358                        $tpl->assign( "form_error_msg", "Got " . $tdb->resultcount . " search results, output limited to last " . $SEARCH_RESULT_LIMIT . " jobs." );
     359                        $tpl->gotoBlock( "search_results" );
     360                }
    353361
    354362                $jobs = array();
Note: See TracChangeset for help on using the changeset viewer.