SearchKit - Fix broken totals row and query output
authorcolemanw <coleman@civicrm.org>
Tue, 29 Aug 2023 18:54:25 +0000 (14:54 -0400)
committercolemanw <coleman@civicrm.org>
Sun, 3 Sep 2023 16:16:24 +0000 (12:16 -0400)
This regressed in ef1cbd

ext/search_kit/ang/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.component.js
ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.component.js

index 68c2dbda744430432489dfb117e67659351de238..b682eaa657919e68e6dc3dfdcb0b8d3b46b7835f 100644 (file)
 
       // 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);
       });
 
index 59372abd768ccce312a7b759c671c4c19d97430c..7530c34153dbc81f41bb51f36b983b5cc2d89cb1 100644 (file)
       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) {