- Updates Segment model to return subscriber count only if subscriber's
status is "subscribed"
This commit is contained in:
@@ -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,
|
||||||
|
Reference in New Issue
Block a user