[Reconnoiter-devel] [reconnoiter commit] r459 - in trunk/ui/web: htdocs/css lib

svn-commit at lists.omniti.com svn-commit at lists.omniti.com
Fri Sep 26 11:16:42 EDT 2008


Author: jesus
Date: 2008-09-26 11:16:42 -0400 (Fri, 26 Sep 2008)
New Revision: 459

Modified:
   trunk/ui/web/htdocs/css/style.css
   trunk/ui/web/lib/Reconnoiter_DB.php
Log:
make search better. refs #22

Modified: trunk/ui/web/htdocs/css/style.css
===================================================================
--- trunk/ui/web/htdocs/css/style.css	2008-09-26 12:29:24 UTC (rev 458)
+++ trunk/ui/web/htdocs/css/style.css	2008-09-26 15:16:42 UTC (rev 459)
@@ -38,7 +38,7 @@
 left:0;
 top:65px;
 padding:0;
-width:333px;
+width:334px;
 height:85%;
 z-index:200;
 } 

Modified: trunk/ui/web/lib/Reconnoiter_DB.php
===================================================================
--- trunk/ui/web/lib/Reconnoiter_DB.php	2008-09-26 12:29:24 UTC (rev 458)
+++ trunk/ui/web/lib/Reconnoiter_DB.php	2008-09-26 15:16:42 UTC (rev 459)
@@ -73,34 +73,44 @@
   }
   protected function run_tsearch($searchstring, $countsql, $datasql, $offset, $limit) {
     $searchstring = $this->tsearchize($searchstring);
-    $searchwhere = $searchstring ? 'ts_search_all @@ to_tsquery(?)' : 'true';
 
-    $binds = array();
-    if($searchstring) array_unshift($binds, $searchstring);
-    $sth = $this->db->prepare(sprintf($countsql,$searchwhere));
+    $binds = array($searchstring);
+    $sth = $this->db->prepare($countsql);
     $sth->execute($binds);
     $r = $sth->fetch();
 
     array_push($binds, $limit);
     array_push($binds, $offset);
-    $sth = $this->db->prepare(sprintf("$datasql limit ? offset ?",
-                              $searchwhere));
+    $sth = $this->db->prepare("$datasql limit ? offset ?");
     $sth->execute($binds);
     $a = array();
     while($row = $sth->fetch()) $a[] = $row;
-
     return array('query' => $searchstring, 'limit' => $limit,
                  'offset' => $offset, count => $r['count'], 'results' => $a);
   }
   function get_graphs($searchstring, $offset, $limit) {
     return $this->run_tsearch($searchstring,
       "select count(*) as count
-         from prism.saved_graphs
-        where saved = true and %s",
+         from prism.saved_graphs,
+              (select ? ::text as query) q
+        where saved = true and
+           ((ts_search_all @@ to_tsquery(query) or query = '')
+            or graphid in (select graphid
+                            from prism.saved_graphs_dep gd
+                            join stratcon.metric_name_summary s
+                           using (sid,metric_name,metric_type)
+                           where ts_search_all @@ to_tsquery(query)))",
       "select graphid, title,
               to_char(last_update, 'YYYY/mm/dd') as last_update
-         from prism.saved_graphs
-        where saved = true and %s
+         from prism.saved_graphs,
+              (select ? ::text as query) q
+        where saved = true and
+           ((ts_search_all @@ to_tsquery(query) or query = '')
+            or graphid in (select graphid
+                            from prism.saved_graphs_dep gd
+                            join stratcon.metric_name_summary s
+                           using (sid,metric_name,metric_type)
+                           where ts_search_all @@ to_tsquery(query)))
      order by last_update desc",
       $offset, $limit);
   }
@@ -108,14 +118,16 @@
     return $this->run_tsearch($searchstring,
       "select count(*) as count
          from stratcon.mv_loading_dock_check_s c
-         join stratcon.metric_name_summary m using (sid)
-        where active = true and %s",
+         join stratcon.metric_name_summary m using (sid),
+              (select ? ::text as query) q
+        where active = true and (query = '' or ts_search_all @@ to_tsquery(query))",
       "select c.id, c.sid, c.remote_address,
               c.target, c.whence, c.module, c.name,
               m.metric_name, m.metric_type
          from stratcon.mv_loading_dock_check_s c
-         join stratcon.metric_name_summary m using (sid)
-        where active = true and %s
+         join stratcon.metric_name_summary m using (sid),
+              (select ? ::text as query) q
+        where active = true and (query = '' or ts_search_all @@ to_tsquery(query))
      order by target, module, name, remote_address",
       $offset, $limit);
   }



More information about the Reconnoiter-devel mailing list