Changeset 90b4360093c1f6e28d53a8b221352b215d0d6f89
- Timestamp:
- 09/26/08 15:16:42
(5 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
| r668d3a3 |
r90b4360 |
|
| 39 | 39 | top:65px; |
|---|
| 40 | 40 | padding:0; |
|---|
| 41 | | width:333px; |
|---|
| | 41 | width:334px; |
|---|
| 42 | 42 | height:85%; |
|---|
| 43 | 43 | z-index:200; |
|---|
| r648b048 |
r90b4360 |
|
| 74 | 74 | protected function run_tsearch($searchstring, $countsql, $datasql, $offset, $limit) { |
|---|
| 75 | 75 | $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); |
|---|
| 81 | 79 | $sth->execute($binds); |
|---|
| 82 | 80 | $r = $sth->fetch(); |
|---|
| … | … | |
| 84 | 82 | array_push($binds, $limit); |
|---|
| 85 | 83 | array_push($binds, $offset); |
|---|
| 86 | | $sth = $this->db->prepare(sprintf("$datasql limit ? offset ?", |
|---|
| 87 | | $searchwhere)); |
|---|
| | 84 | $sth = $this->db->prepare("$datasql limit ? offset ?"); |
|---|
| 88 | 85 | $sth->execute($binds); |
|---|
| 89 | 86 | $a = array(); |
|---|
| 90 | 87 | while($row = $sth->fetch()) $a[] = $row; |
|---|
| 91 | | |
|---|
| 92 | 88 | return array('query' => $searchstring, 'limit' => $limit, |
|---|
| 93 | 89 | 'offset' => $offset, count => $r['count'], 'results' => $a); |
|---|
| … | … | |
| 96 | 92 | return $this->run_tsearch($searchstring, |
|---|
| 97 | 93 | "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)))", |
|---|
| 100 | 103 | "select graphid, title, |
|---|
| 101 | 104 | 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))) |
|---|
| 104 | 114 | order by last_update desc", |
|---|
| 105 | 115 | $offset, $limit); |
|---|
| … | … | |
| 109 | 119 | "select count(*) as count |
|---|
| 110 | 120 | 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))", |
|---|
| 113 | 124 | "select c.id, c.sid, c.remote_address, |
|---|
| 114 | 125 | c.target, c.whence, c.module, c.name, |
|---|
| 115 | 126 | m.metric_name, m.metric_type |
|---|
| 116 | 127 | 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)) |
|---|
| 119 | 131 | order by target, module, name, remote_address", |
|---|
| 120 | 132 | $offset, $limit); |
|---|