[Rt-commit] rt branch 5.0/modify-query-builder-default-results created. rt-5.0.3-180-g50b90e8723

BPS Git Server git at git.bestpractical.com
Fri Dec 2 14:39:16 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/modify-query-builder-default-results has been created
        at  50b90e87231a7e31e427aee06f809309cf57d153 (commit)

- Log -----------------------------------------------------------------
commit 50b90e87231a7e31e427aee06f809309cf57d153
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Fri Dec 2 09:37:17 2022 -0500

    Make search results per page configurable in RT UI

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index b659fbc291..fdd0a243ab 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -362,6 +362,27 @@ our %META;
             }
         },
     },
+    DefaultSearchResultRowsPerPage => {
+        Section         => 'General',                       #loc
+        Overridable     => 1,
+        Default         => 50,
+        SortOrder       => 9,
+        Widget          => '/Widgets/Form/Select',
+        WidgetArguments => {
+            Description => 'Number of search results per page', #loc
+            Callback    => sub {
+                my @values = RT->Config->Get('SearchResultsPerPage');
+                my %labels = (
+                    0 => "Unlimited", # loc
+                    map { $_ => $_ } @values,
+                );
+
+                unshift @values, 0;
+
+                return { Values => \@values, ValuesLabel => \%labels };
+            },
+        },
+    },
     SearchResultsRefreshInterval => {
         Section         => 'General',                       #loc
         Overridable     => 1,

commit ee791fc83d3326c1991882e4e3b649103f5ca32c
Author: Jason Crome <jcrome at bestpractical.com>
Date:   Mon Sep 26 13:30:44 2022 -0400

    Make # of search results per-page configurable
    
    On larger databases with many tickets and lots of custom roles,
    displaying a page of 50 search results may become slow. Adjusting the
    number of rows of search results per page can result in better
    performance in these cases.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index bd9c001d28..57c5d02d28 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2241,7 +2241,7 @@ Set($SearchResultsRefreshInterval, 0);
 =item C<$DefaultSearchResultFormat>
 
 C<$DefaultSearchResultFormat> is the default format for RT search
-results
+results.
 
 =cut
 
@@ -2260,6 +2260,25 @@ Set ($DefaultSearchResultFormat, qq{
    '<small>__LastUpdatedRelative__</small>',
    '<small>__TimeLeft__</small>'});
 
+=item C<$DefaultSearchResultRowsPerPage>
+
+C<$DefaultSearchResultRowsPerPage> is the default rows per page for
+the dropdown on the Query Builder. Users can still easily change it
+by selecting another value from the dropdown before they run their
+search.
+
+=cut
+
+Set( $DefaultSearchResultRowsPerPage, 50 );
+
+=item C<@SearchResultsPerPage>
+
+This setting defines the possible choices for search results per page. You should
+You should not include a value of C<0>, as that is always provided as an option.
+
+=cut
+
+Set(@SearchResultsPerPage, qw(10 25 50 100));
 
 =item C<$UserTicketDataResultFormat>
 
diff --git a/share/html/Elements/SelectResultsPerPage b/share/html/Elements/SelectResultsPerPage
index a1757df003..660b85fb42 100644
--- a/share/html/Elements/SelectResultsPerPage
+++ b/share/html/Elements/SelectResultsPerPage
@@ -56,8 +56,9 @@
 </select>
 
 <%INIT>
-my @values = qw(0 10 25 50 100);
-my @labels = (loc('Unlimited'), qw(10 25 50 100));
+my @values = RT->Config->Get('SearchResultsPerPage');
+my @labels = (loc('Unlimited'), @values);
+unshift @values, 0;
 $Default = 50 unless defined $Default && $Default =~ /^\d+$/;
 </%INIT>
 <%ARGS>
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 2f3be5f914..6a7f7e23d7 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -203,7 +203,7 @@ if ( $NewQuery ) {
         OrderBy => $orderby{$Class},
         Order => $order{$Class},
         ObjectType  => $ObjectType,
-        RowsPerPage => 50
+        RowsPerPage => RT->Config->Get('DefaultSearchResultRowsPerPage') || 50
     };
 
     for( qw(Query Format OrderBy Order RowsPerPage ObjectType) ) {
diff --git a/share/html/Search/Edit.html b/share/html/Search/Edit.html
index a46bfb737e..054fe7416a 100644
--- a/share/html/Search/Edit.html
+++ b/share/html/Search/Edit.html
@@ -109,7 +109,7 @@ $SavedSearchId => 'new'
 $SavedChartSearchId => 'new'
 $Query         => ''
 $Format        => ''
-$Rows          => '50'
+$Rows          => RT->Config->Get('DefaultSearchResultRowsPerPage') || '50'
 $Order         => 'ASC'
 $Class         => 'RT::Tickets'
 $OrderBy       => $Class eq 'RT::Assets' ? 'Name' : 'id'
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index 6871e702bb..d676a6cbc5 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -431,8 +431,9 @@ return @results;
 
 <%METHOD GetDependedOnByList>
 
+% my $rows_per_page = RT->Config->Get('DefaultSearchResultRowsPerPage') || 50;
 % my $links = $Object->DependedOnBy;
-% $links->RowsPerPage(50);
+% $links->RowsPerPage( $rows_per_page );
 % my $total = $links->CountAll;
   <p>
     <&|/l, $total &>This search is used in the following [quant,_1,dashboard,dashboards]</&>:
@@ -448,7 +449,7 @@ return @results;
     </li>
 % }
 
-% if ( $total > 50 ) {
+% if ( $total > $rows_per_page ) {
     <li class="list-group-item">...</li>
 % }
   </ul>
diff --git a/share/html/Search/Results.html b/share/html/Search/Results.html
index 768b2d5ef6..752b55133e 100644
--- a/share/html/Search/Results.html
+++ b/share/html/Search/Results.html
@@ -156,7 +156,7 @@ if ( !defined($Rows) ) {
     } elsif ( defined $prefs->{'RowsPerPage'} ) {
         $Rows = $prefs->{'RowsPerPage'};
     } else {
-        $Rows = 50;
+        $Rows = RT->Config->Get('DefaultSearchResultRowsPerPage') || 50;
     }
 }
 $Page = 1 unless $Page && $Page > 0;

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list