[Midnightbsd-cvs] mports: index.cgi: start of improved searching, can do things like "curl
ctriv at midnightbsd.org
ctriv at midnightbsd.org
Fri Mar 21 16:41:41 EDT 2008
Log Message:
-----------
start of improved searching, can do things like "curl status:fail" or
"run:12 status:pass" can't do things involving joins yet, so no "curl
arch:i386 status:fail"
Modified Files:
--------------
mports/Tools/magus/www/data/magus:
index.cgi (r1.11 -> r1.12)
-------------- next part --------------
Index: index.cgi
===================================================================
RCS file: /home/cvs/mports/Tools/magus/www/data/magus/index.cgi,v
retrieving revision 1.11
retrieving revision 1.12
diff -L Tools/magus/www/data/magus/index.cgi -L Tools/magus/www/data/magus/index.cgi -u -r1.11 -r1.12
--- Tools/magus/www/data/magus/index.cgi
+++ Tools/magus/www/data/magus/index.cgi
@@ -9,6 +9,16 @@
use HTML::Template;
use JSON::XS;
+#
+# This is a trick we do so that the abstract search stuff isn't required
+# on all the nodes, only the webapp needs this. We'll just slip
+# the search_where() method into Magus::DBI here...
+#
+{
+ package Magus::DBI;
+ use Class::DBI::AbstractSearch;
+}
+
eval {
main();
exit 0;
@@ -221,8 +231,24 @@
my ($p) = @_;
my $query = $p->param('q');
+ my %where;
+ while ($query =~ s/(\S+):(\S+)//) {
+ push(@{$where{$1}}, $2)
+ }
+
+ $query =~ s/^\s*//;
+ $query =~ s/\s*$//;
+ $query =~ s/\*/%/g;
+
+ $where{name} = { like => "%$query%" } if $query;
+ if ($where{status}) {
+ delete $where{status} if grep { m/any/i } @{$where{status}};
+ } else {
+ $where{status} = { '!=', 'untested' };
+ }
+
- my @ports = Magus::Port->retrieve_from_sql("name LIKE ? ORDER BY name", "%$query%");
+ my @ports = Magus::Port->search_where(\%where, { order_by => 'name' });
if (@ports == 1) {
my $id = $ports[0]->id;
More information about the Midnightbsd-cvs
mailing list