CiviMail: distinct events in API Mailing stats
authorscardinius <scardinius@chords.pl>
Mon, 27 Jul 2015 13:43:00 +0000 (15:43 +0200)
committerscardinius <scardinius@chords.pl>
Mon, 27 Jul 2015 13:43:00 +0000 (15:43 +0200)
ang/crmMailing/services.js
api/v3/Mailing.php

index 6a155c93b05b21d270ff1a6aa313b1a2f82a5b7f..b51e0e852c15c004efba7c290fe2ce95ce62f284 100644 (file)
       getStats: function(mailingIds) {
         var params = {};
         angular.forEach(mailingIds, function(mailingId, name) {
-          params[name] = ['Mailing', 'stats', {mailing_id: mailingId}];
+          params[name] = ['Mailing', 'stats', {mailing_id: mailingId, is_distinct: 0}];
         });
         return crmApi(params).then(function(result) {
           var stats = {};
index 46c97b86d82c2313b3f8f8dcdf2f86988f5767b4..caa7ffb103afd197c7608d4758ee1b9347390822 100755 (executable)
@@ -693,31 +693,31 @@ function civicrm_api3_mailing_stats($params) {
     switch ($detail) {
       case 'Delivered':
         $stats[$params['mailing_id']] += array(
-          $detail => CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+          $detail => CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], (bool)$params['is_distinct'], $params['date']),
         );
         break;
 
       case 'Bounces':
         $stats[$params['mailing_id']] += array(
-          $detail => CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+          $detail => CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], (bool)$params['is_distinct'], $params['date']),
         );
         break;
 
       case 'Unsubscribers':
         $stats[$params['mailing_id']] += array(
-          $detail => CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
+          $detail => CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], (bool)$params['is_distinct'], NULL, $params['date']),
         );
         break;
 
       case 'Unique Clicks':
         $stats[$params['mailing_id']] += array(
-          $detail => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
+          $detail => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], (bool)$params['is_distinct'], NULL, $params['date']),
         );
         break;
 
       case 'Opened':
         $stats[$params['mailing_id']] += array(
-          $detail => CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+          $detail => CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], (bool)$params['is_distinct'], $params['date']),
         );
         break;
     }