diff options
author | Jeff Fearn <jfearn@redhat.com> | 2021-08-18 13:18:21 +1000 |
---|---|---|
committer | Jeff Fearn <jfearn@redhat.com> | 2021-08-18 13:18:21 +1000 |
commit | 192d9aa9cbd19c388c46ceebc61b620996b574b3 (patch) | |
tree | 58b97056b677f3740122ef37afb4c3a8e6372e25 /Bugzilla/Search.pm | |
parent | Bug 1825332 - Bad comment numbering on emails with multiple comments (diff) | |
download | bugzilla-192d9aa9cbd19c388c46ceebc61b620996b574b3.tar.gz bugzilla-192d9aa9cbd19c388c46ceebc61b620996b574b3.tar.bz2 bugzilla-192d9aa9cbd19c388c46ceebc61b620996b574b3.zip |
Bug 1347097 - Add ajax to DataTables to allow fetching subsets of data
Updated JQuery to 3.6.0
Updated JQueryUI to 1.12.1
Updated DataTables to 1.10.25
Modified Bug List to use AJAX and pagination
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r-- | Bugzilla/Search.pm | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 27f4cd26f..c0a8f8c33 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -900,6 +900,76 @@ END return $self->{sql}; } +## REDHAT EXTENSION START 1347097 +sub sql_count { + my ($self) = @_; + +# return $self->{sql_count} if $self->{sql_count}; + my $dbh = Bugzilla->dbh; + + ## BUGBUG description gets duplicated... + delete $self->{'search_description'}; + + my ($joins, $clause) = $self->_charts_to_conditions(); + + if ( !$clause->as_string + && !Bugzilla->params->{'search_allow_no_criteria'} + && !$self->{allow_unlimited}) + { + ThrowUserError('buglist_parameters_required'); + } + + my $select = "count(*)"; + my $from = $self->_sql_from($joins); + my $where = $self->_sql_where($clause); + my $group_by = ''; + + my $query = <<END; +SELECT $select + FROM $from + WHERE $where +$group_by +END + $self->{sql_count} = $dbh->selectrow_array($query); + return $self->{sql_count}; +} + +sub bug_ids { + my $self = shift; + if (!$self->{bug_ids}) { + my $dbh = Bugzilla->dbh; + + my $orig_fields = $self->{fields}; + $self->{fields} = ['bug_id']; + + my $start_time = [gettimeofday()]; + my $sql = $self->_sql; + $sql =~ s/LIMIT.*//; + + $sql .= ' /* ' . ($self->_user->email || 'Unknown') . ' */'; + + my $bug_ids = []; + + my $sth = $dbh->prepare($sql); + + if (!$dbh->bz_call_with_timeout($sth)) { + ThrowUserError("query_timeout", + {timeout => Bugzilla->params->{'long_query_timeout'}}); + } + + push @{Bugzilla->request_cache->{_rh_query_history}}, + {sql => $sql, time => tv_interval($start_time)}; + + $bug_ids = $sth->fetchall_arrayref(); + $bug_ids = [map { $_->[0] } @$bug_ids]; + $self->{bug_ids} = $bug_ids; + $self->{fields} = $orig_fields; + } + + return $self->{bug_ids}; +} +## REDHAT EXTENSION END 1347097 + sub search_description { my ($self, $params) = @_; my $desc = $self->{'search_description'} ||= []; @@ -4016,6 +4086,14 @@ required data. =back +=head2 sql_count + +This function runs the search and only returns the count of bugs that match. + +=head2 bug_ids + +This function runs the search and only returns the IDs of bugs that match. + =head1 B<Methods in need of POD> =over |