summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2014-02-06 07:39:40 +0100
committerByron Jones <bjones@mozilla.com>2014-02-06 07:39:40 +0100
commit8679e81c45ee25f4db6bbe98bfa542b68532782e (patch)
tree76ea930f9205c4ccdd9dd6f7e72c366fce6859e9 /Bugzilla
parenteae63571ef63f7ddc9f36219229075a20c012d55 (diff)
downloadbugzilla-8679e81c45ee25f4db6bbe98bfa542b68532782e.tar.gz
bugzilla-8679e81c45ee25f4db6bbe98bfa542b68532782e.tar.xz
Bug 967607: User.get shouldn't load data that requires extra database queries unless required
r=dkl, a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/WebService/User.pm32
1 files changed, 21 insertions, 11 deletions
diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm
index 22306a11f..09585ebfe 100644
--- a/Bugzilla/WebService/User.pm
+++ b/Bugzilla/WebService/User.pm
@@ -17,7 +17,7 @@ use Bugzilla::Error;
use Bugzilla::Group;
use Bugzilla::User;
use Bugzilla::Util qw(trim);
-use Bugzilla::WebService::Util qw(filter validate translate params_to_objects);
+use Bugzilla::WebService::Util qw(filter filter_wants validate translate params_to_objects);
use List::Util qw(first);
@@ -226,9 +226,7 @@ sub get {
}
}
- my $in_group = $self->_filter_users_by_group(
- \@user_objects, $params);
-
+ my $in_group = $self->_filter_users_by_group(\@user_objects, $params);
foreach my $user (@$in_group) {
my $user_info = {
id => $self->type('int', $user->id),
@@ -244,15 +242,27 @@ sub get {
}
if (Bugzilla->user->id == $user->id) {
- $user_info->{saved_searches} = [map { $self->_query_to_hash($_) } @{ $user->queries }];
- $user_info->{saved_reports} = [map { $self->_report_to_hash($_) } @{ $user->reports }];
+ if (filter_wants($params, 'saved_searches')) {
+ $user_info->{saved_searches} = [
+ map { $self->_query_to_hash($_) } @{ $user->queries }
+ ];
+ }
+ if (filter_wants($params, 'saved_reports')) {
+ $user_info->{saved_reports} = [
+ map { $self->_report_to_hash($_) } @{ $user->reports }
+ ];
+ }
}
- if (Bugzilla->user->id == $user->id || Bugzilla->user->in_group('editusers')) {
- $user_info->{groups} = [map {$self->_group_to_hash($_)} @{ $user->groups }];
- }
- else {
- $user_info->{groups} = $self->_filter_bless_groups($user->groups);
+ if (filter_wants($params, 'groups')) {
+ if (Bugzilla->user->id == $user->id || Bugzilla->user->in_group('editusers')) {
+ $user_info->{groups} = [
+ map { $self->_group_to_hash($_) } @{ $user->groups }
+ ];
+ }
+ else {
+ $user_info->{groups} = $self->_filter_bless_groups($user->groups);
+ }
}
push(@users, filter($params, $user_info));