From 7dc1a37e806bb674a6e5929a1a9a1db546c03aab Mon Sep 17 00:00:00 2001 From: colemanw Date: Tue, 29 Aug 2023 14:54:25 -0400 Subject: [PATCH] SearchKit - Fix broken totals row and query output This regressed in ef1cbd --- .../resultsTable/crmSearchAdminResultsTable.component.js | 4 +++- .../crmSearchDisplayTable/crmSearchDisplayTable.component.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.component.js b/ext/search_kit/ang/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.component.js index 68c2dbda74..b682eaa657 100644 --- a/ext/search_kit/ang/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.component.js @@ -43,10 +43,12 @@ // Add callbacks for pre & post run this.onPreRun.push(function(apiCalls) { - apiCalls.run.debug = true; + // So the raw SQL can be shown in the "Query Info" tab + apiCalls.run[2].debug = true; }); this.onPostRun.push(function(apiResults) { + // Add debug output (e.g. raw SQL) to the "Query Info" tab ctrl.debug = _.extend(_.pick(ctrl.debug, 'apiParams'), apiResults.run.debug); }); diff --git a/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js b/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js index 59372abd76..7530c34153 100644 --- a/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js +++ b/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js @@ -22,10 +22,11 @@ this.$onInit = function() { var tallyParams; + // Copy API params from the run and adapt them in a secondary `tally` call for the "Totals" row if (ctrl.settings.tally) { ctrl.onPreRun.push(function (apiCalls) { ctrl.tally = null; - tallyParams = _.cloneDeep(apiCalls.run); + tallyParams = _.cloneDeep(apiCalls.run[2]); }); ctrl.onPostRun.push(function (apiResults, status) { -- 2.25.1