From 00eaa768a6da4f6113cfaac4309e118bc3d12007 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 11 May 2016 13:06:26 -0400 Subject: [PATCH] - Updates Segment model to return subscriber count only if subscriber's status is "subscribed" --- lib/Models/Segment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Models/Segment.php b/lib/Models/Segment.php index 05055b281b..1b97d2f62f 100644 --- a/lib/Models/Segment.php +++ b/lib/Models/Segment.php @@ -127,7 +127,7 @@ class Segment extends Model { static function getSegmentsWithSubscriberCount() { return self::selectMany(array(self::$_table.'.id', self::$_table.'.name')) ->selectExpr( - self::$_table.'.*, COUNT('.MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id) `subscribers`' + self::$_table.'.*, COUNT(IF('.MP_SUBSCRIBER_SEGMENT_TABLE.'.status="subscribed",1,NULL)) `subscribers`' ) ->leftOuterJoin( MP_SUBSCRIBER_SEGMENT_TABLE,