[Rt-commit] rt branch 5.0/search-url-shortener updated. rt-5.0.2-297-gc932ced207

BPS Git Server git at git.bestpractical.com
Thu Jan 19 22:38:34 UTC 2023


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/search-url-shortener has been updated
       via  c932ced207a548b8d4a93a60edca6d9bedc56561 (commit)
       via  26aad9a617027a5466f52342ae6d3ea3301db1d7 (commit)
      from  26690bc81c53b5b3362e2774933c3c9b1990ac05 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c932ced207a548b8d4a93a60edca6d9bedc56561
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jan 19 16:51:36 2023 +0800

    Avoid adding duplicated criteria to queries generated on chart page
    
    For a bar chart grouped by status, each bar represents one status, and
    clicking it redirects to search result page that shows tickets with that
    status only. This is achieved by adding the extra status criterion to
    the original query, e.g. TicketSQL is changed from:
    
        Queue = 'General'
    
    to
    
        (Queue = 'General') AND (Status = 'new')
    
    If you go to Chart page and click again, previously we unconditionally
    added the extra status criterion, so the TicketSQL would be
    
        ((Queue = 'General') AND (Status = 'new')) AND (Status = 'new')
    
    which is unnecessary. This commit checks the queries beforehand to avoid
    the duplication for both js charts and tables.

diff --git a/share/html/Search/Elements/ChartTable b/share/html/Search/Elements/ChartTable
index 9a4ed83bb7..83f4c4ce52 100644
--- a/share/html/Search/Elements/ChartTable
+++ b/share/html/Search/Elements/ChartTable
@@ -93,9 +93,9 @@ foreach my $section (qw(thead tbody tfoot)) {
                             QueryString(
                                 ShortenSearchQuery(
                                     %base_query,
-                                    Query => join( ' AND ',
-                                        map { /^\s*\(.*\)$/ ? $_ : "($_)" }
-                                        grep { defined and length } $Query, $q ),
+                                    Query => $Query =~ /^\s*\(.*\) AND \(?\Q$q\E\)?$/
+                                    ? $Query
+                                    : join( ' AND ', map { /^\s*\(.*\)$/ ? $_ : "($_)" } $Query, $q ),
                                 )
                             )
                         )
diff --git a/share/html/Search/JSChart b/share/html/Search/JSChart
index e298cefcb7..4ca61b5bda 100644
--- a/share/html/Search/JSChart
+++ b/share/html/Search/JSChart
@@ -214,12 +214,15 @@ my @data_queries;
 while ( my $entry = $report->Next ) {
     push @{ $data[0] }, [ map $entry->LabelValue( $_ ), @{ $columns{'Groups'} } ];
 
+    my $q = $entry->Query;
     push @data_queries,
         QueryString(
             ShortenSearchQuery(
                 map( { $_ => $ARGS{$_} }
                     grep { defined $ARGS{$_} and length $ARGS{$_} } @RT::Interface::Web::SHORTENER_SEARCH_FIELDS ),
-                Query => join( ' AND ', map { /^\s*\(.*\)$/ ? $_ : "($_)" } $Query, $entry->Query ),
+                Query => $Query =~ /^\s*\(.*\) AND \(?\Q$q\E\)?$/
+                ? $Query
+                : join( ' AND ', map { /^\s*\(.*\)$/ ? $_ : "($_)" } $Query, $q ),
             )
         );
 

commit 26aad9a617027a5466f52342ae6d3ea3301db1d7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jan 19 17:25:44 2023 +0800

    Default query to "id > 0" like other chart elements for ChartTable
    
    In the edge case where Query is not set, this commit makes generated
    subqueries in ChartTable consistent with JSChart.

diff --git a/share/html/Search/Elements/ChartTable b/share/html/Search/Elements/ChartTable
index 4ef91031b7..9a4ed83bb7 100644
--- a/share/html/Search/Elements/ChartTable
+++ b/share/html/Search/Elements/ChartTable
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%ARGS>
 %Table => ()
-$Query => undef
+$Query => 'id > 0'
 </%ARGS>
 <%INIT>
 

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

Summary of changes:
 share/html/Search/Elements/ChartTable | 8 ++++----
 share/html/Search/JSChart             | 5 ++++-
 2 files changed, 8 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list