Skip to content

Commit

Permalink
add basic "by owner" query
Browse files Browse the repository at this point in the history
...in a really, really, REALLY ugly way.
  • Loading branch information
rsrchboy committed Mar 31, 2010
1 parent 23d346c commit 722bb43
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
21 changes: 16 additions & 5 deletions lib/Fedora/App/Updates/Controller/REST.pm
Expand Up @@ -120,18 +120,29 @@ sub packages_GET {
sub query_to_dbic {
my ($self, $c) = @_;

# We only look for name here at the moment... this should be extended as
# needed later.
return unless my $name = $c->req->parameters->{name};
# FIXME this needs refactoring... ew
my $name = $c->req->parameters->{name};
my $owner = $c->req->parameters->{owner};

my $search = {};

if ($name =~ /\*/) {

# if we're a wildcard search...
$name =~ s/\*/%/g;
return { 'me.name' => { LIKE => $name } };
$search->{'me.name'} = { LIKE => $name };
}
elsif ($name) { $search->{'me.name'} = $name }

if ($owner =~ /\*/) {

# if we're a wildcard search...
$owner =~ s/\*/%/g;
$search->{'me.owner_id'} = { LIKE => $owner };
}
elsif ($owner) { $search->{'me.owner_id'} = $owner }

return { 'me.name' => $name };
return $search;
}

__PACKAGE__->meta->make_immutable;
Expand Down
8 changes: 8 additions & 0 deletions lib/Fedora/App/Updates/Controller/Root.pm
Expand Up @@ -21,6 +21,14 @@ sub index : Path Args(0) {
;
$c->stash->{dists} = \@dists;

my @users = $c
->model('Updates::Users')
->search(undef, { order_by => 'id' })
->get_column('id')
->all
;
$c->stash->{users} = \@users;

return;
}

Expand Down
15 changes: 13 additions & 2 deletions root/src/index.tt2
Expand Up @@ -81,7 +81,8 @@ function format_rawhide(value) { format_cell('rawhide', value); }
it really ought to be for this.)
-%]

<span dojoType="dojox.data.JsonRestStore" jsId="packagesStore" target="/rest/packages"></span>
<span dojoType="dojox.data.JsonRestStore" jsId="packageStore" target="/rest/packages"></span>
<span dojoType="dojox.data.JsonRestStore" jsId="userStore" target="/rest/users"></span>

<div dojoType="dijit.layout.BorderContainer" design="headline" style="width: 100%; height: 100%;" gutters="true" liveSplitters="true" id="borderContainer">

Expand All @@ -96,13 +97,23 @@ function format_rawhide(value) { format_cell('rawhide', value); }
<option value="{ name: 'perl-Catalyst*' }" >perl-Catalyst (all)</option>
<option value="{ name: 'perl-CGI-Application*' }" >perl-CGI-Application (all)</option>
<option value="{ name: 'perl-Moose*' }" >perl-Moose (all)</option>
<option value="{ name: 'php*' }" >PHP Packages</option>
</select>

<select dojoType="dijit.form.FilteringSelect" id="users_select" name="users_select">
<script type="dojo/method" event="onChange">
packagesGrid.setQuery(dojo.fromJson(this.value));
</script>
<option value="{ owner: '*' }" selected >All Owners</option>
[% FOREACH user = users -%]
<option value="{ owner: '[% user %]' }" >[% user | html %]</option>
[% END -%]
</select>
</div>

<table
dojoType="dojox.grid.EnhancedGrid"
store="packagesStore"
store="packageStore"
query="{ name: 'perl-*' }"
jsId="packagesGrid"
rowsPerPage="150"
Expand Down

0 comments on commit 722bb43

Please sign in to comment.