Changeset 90b4360093c1f6e28d53a8b221352b215d0d6f89

Show
Ignore:
Timestamp:
09/26/08 15:16:42 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1222442202 +0000
git-parent:

[648b048a9c5f5d8e0fb7d6ed20f40a352d602688]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1222442202 +0000
Message:

make search better. refs #22

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/css/style.css

    r668d3a3 r90b4360  
    3939top:65px; 
    4040padding:0; 
    41 width:333px; 
     41width:334px; 
    4242height:85%; 
    4343z-index:200; 
  • ui/web/lib/Reconnoiter_DB.php

    r648b048 r90b4360  
    7474  protected function run_tsearch($searchstring, $countsql, $datasql, $offset, $limit) { 
    7575    $searchstring = $this->tsearchize($searchstring); 
    76     $searchwhere = $searchstring ? 'ts_search_all @@ to_tsquery(?)' : 'true'; 
    77  
    78     $binds = array(); 
    79     if($searchstring) array_unshift($binds, $searchstring); 
    80     $sth = $this->db->prepare(sprintf($countsql,$searchwhere)); 
     76 
     77    $binds = array($searchstring); 
     78    $sth = $this->db->prepare($countsql); 
    8179    $sth->execute($binds); 
    8280    $r = $sth->fetch(); 
     
    8482    array_push($binds, $limit); 
    8583    array_push($binds, $offset); 
    86     $sth = $this->db->prepare(sprintf("$datasql limit ? offset ?", 
    87                               $searchwhere)); 
     84    $sth = $this->db->prepare("$datasql limit ? offset ?"); 
    8885    $sth->execute($binds); 
    8986    $a = array(); 
    9087    while($row = $sth->fetch()) $a[] = $row; 
    91  
    9288    return array('query' => $searchstring, 'limit' => $limit, 
    9389                 'offset' => $offset, count => $r['count'], 'results' => $a); 
     
    9692    return $this->run_tsearch($searchstring, 
    9793      "select count(*) as count 
    98          from prism.saved_graphs 
    99         where saved = true and %s", 
     94         from prism.saved_graphs, 
     95              (select ? ::text as query) q 
     96        where saved = true and 
     97           ((ts_search_all @@ to_tsquery(query) or query = '') 
     98            or graphid in (select graphid 
     99                            from prism.saved_graphs_dep gd 
     100                            join stratcon.metric_name_summary s 
     101                           using (sid,metric_name,metric_type) 
     102                           where ts_search_all @@ to_tsquery(query)))", 
    100103      "select graphid, title, 
    101104              to_char(last_update, 'YYYY/mm/dd') as last_update 
    102          from prism.saved_graphs 
    103         where saved = true and %s 
     105         from prism.saved_graphs, 
     106              (select ? ::text as query) q 
     107        where saved = true and 
     108           ((ts_search_all @@ to_tsquery(query) or query = '') 
     109            or graphid in (select graphid 
     110                            from prism.saved_graphs_dep gd 
     111                            join stratcon.metric_name_summary s 
     112                           using (sid,metric_name,metric_type) 
     113                           where ts_search_all @@ to_tsquery(query))) 
    104114     order by last_update desc", 
    105115      $offset, $limit); 
     
    109119      "select count(*) as count 
    110120         from stratcon.mv_loading_dock_check_s c 
    111          join stratcon.metric_name_summary m using (sid) 
    112         where active = true and %s", 
     121         join stratcon.metric_name_summary m using (sid), 
     122              (select ? ::text as query) q 
     123        where active = true and (query = '' or ts_search_all @@ to_tsquery(query))", 
    113124      "select c.id, c.sid, c.remote_address, 
    114125              c.target, c.whence, c.module, c.name, 
    115126              m.metric_name, m.metric_type 
    116127         from stratcon.mv_loading_dock_check_s c 
    117          join stratcon.metric_name_summary m using (sid) 
    118         where active = true and %s 
     128         join stratcon.metric_name_summary m using (sid), 
     129              (select ? ::text as query) q 
     130        where active = true and (query = '' or ts_search_all @@ to_tsquery(query)) 
    119131     order by target, module, name, remote_address", 
    120132      $offset, $limit);