From 37c8ef5cb2750f8039f3b26422d5a5c7cfc61f59 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Fri, 30 Nov 2012 15:03:59 -0500 Subject: Current dashboard work --- extensions/MyDashboard/lib/WebService.pm | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'extensions/MyDashboard/lib/WebService.pm') diff --git a/extensions/MyDashboard/lib/WebService.pm b/extensions/MyDashboard/lib/WebService.pm index 78285ca06..853ef2baf 100644 --- a/extensions/MyDashboard/lib/WebService.pm +++ b/extensions/MyDashboard/lib/WebService.pm @@ -11,8 +11,18 @@ use warnings; use base qw(Bugzilla::WebService); +use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Util qw(detaint_natural trick_taint); +use Bugzilla::WebService::Util qw(validate); + +use Bugzilla::Extension::MyDashboard::Queries qw(QUERY_DEFS query_bugs query_flags); + +use constant READ_ONLY => qw( + prod_comp_search + run_bug_query + run_flag_query +); sub prod_comp_search { my ($self, $params) = @_; @@ -80,6 +90,44 @@ sub prod_comp_search { return { products => $products }; } +sub run_bug_query { + my($self, $params) = @_; + my $user = Bugzilla->login(LOGIN_REQUIRED); + + defined $params->{query} + || ThrowCodeError('param_required', + { function => 'MyDashboard.run_bug_query', + param => 'query' }); + + my $result; + foreach my $qdef (QUERY_DEFS) { + next if $qdef->{name} ne $params->{query}; + my ($bugs, $query_string) = query_bugs($qdef); + $query_string =~ s/^POSTDATA=&//; + $qdef->{bugs} = $bugs; + $qdef->{buffer} = $query_string; + $result = $qdef; + last; + } + + return { result => $result }; +} + +sub run_flag_query { + my ($self, $params) =@_; + my $user = Bugzilla->login(LOGIN_REQUIRED); + + defined $params->{type} + || ThrowCodeError('param_required', + { function => 'MyDashboard.run_flag_query', + param => 'type' }); + + my $type = $params->{type}; + my $results = query_flags($type); + + return { result => { $type => $results }}; +} + 1; __END__ -- cgit v1.2.3-24-g4f1b