[Rt-commit] rt branch 5.0/jschart-avoid-duplicated-criteria created. rt-5.0.3-141-geccfa6e4c8
BPS Git Server
git at git.bestpractical.com
Mon Oct 24 20:58:22 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/jschart-avoid-duplicated-criteria has been created
at eccfa6e4c854cd38984070d29ce3c8d15477ead2 (commit)
- Log -----------------------------------------------------------------
commit eccfa6e4c854cd38984070d29ce3c8d15477ead2
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Oct 25 04:32:34 2022 +0800
Avoid adding duplicated criteria to queries generated in JSChart
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.
diff --git a/share/html/Search/JSChart b/share/html/Search/JSChart
index bc3f9d3ac2..21f4200d45 100644
--- a/share/html/Search/JSChart
+++ b/share/html/Search/JSChart
@@ -177,7 +177,13 @@ jQuery('#search-chart').click(function(e) {
}
% }
if ( extra_query ) {
- query += ' AND ( ' + extra_query + ')';
+ var suffix = ' AND ( ' + extra_query + ' )';
+ var reversed_suffix = suffix.split('').reverse().join('');
+ var reversed_query = query.split('').reverse().join('');
+% # There is no need to re-add if query already has the extra_query at the end
+ if ( reversed_query.indexOf(reversed_suffix) != 0 ) {
+ query += suffix;
+ }
}
window.open(RT.Config.WebPath + '/Search/Results.html?Query=' + encodeURIComponent(query)
+ '&' + <% $m->comp('/Elements/QueryString', map { $_ => $DECODED_ARGS->{$_} } grep { $_ ne 'Query' } keys %$DECODED_ARGS) |n,j%>);
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list