From 92bcb0d9b836c27fa7cbfe57e5de1666be3dde76 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sun, 9 Nov 2008 01:01:39 +0000 Subject: Bug 364162: Code determining if named queries should be shown in the page footer is suboptimal - Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Search/Saved.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Bugzilla/Search') diff --git a/Bugzilla/Search/Saved.pm b/Bugzilla/Search/Saved.pm index 9aa27714d..c8322242b 100644 --- a/Bugzilla/Search/Saved.pm +++ b/Bugzilla/Search/Saved.pm @@ -117,6 +117,24 @@ sub create { return $obj; } +sub preload { + my ($searches) = @_; + my $dbh = Bugzilla->dbh; + + return unless scalar @$searches; + + my @query_ids = map { $_->id } @$searches; + my $queries_in_footer = $dbh->selectcol_arrayref( + 'SELECT namedquery_id + FROM namedqueries_link_in_footer + WHERE ' . $dbh->sql_in('namedquery_id', \@query_ids) . ' AND user_id = ?', + undef, Bugzilla->user->id); + + my %links_in_footer = map { $_ => 1 } @$queries_in_footer; + foreach my $query (@$searches) { + $query->{link_in_footer} = ($links_in_footer{$query->id}) ? 1 : 0; + } +} ##################### # Complex Accessors # ##################### @@ -250,6 +268,12 @@ Does not accept a bare C argument. Instead, accepts only an id. See also: L. +=item C + +Sets C for all given saved searches at once, for the +currently logged in user. This is much faster than calling this method +for each saved search individually. + =back -- cgit v1.2.3-24-g4f1b