- Updates Segment model to return subscriber count only if subscriber's

status is "subscribed"
This commit is contained in:
Vlad
2016-05-11 13:06:26 -04:00
parent bc92d9a61e
commit 00eaa768a6

View File

@@ -127,7 +127,7 @@ class Segment extends Model {
static function getSegmentsWithSubscriberCount() { static function getSegmentsWithSubscriberCount() {
return self::selectMany(array(self::$_table.'.id', self::$_table.'.name')) return self::selectMany(array(self::$_table.'.id', self::$_table.'.name'))
->selectExpr( ->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( ->leftOuterJoin(
MP_SUBSCRIBER_SEGMENT_TABLE, MP_SUBSCRIBER_SEGMENT_TABLE,