- Updates Segment model to return ASC sorted results
- Updates Subscriber listing to display segmnets with count
This commit is contained in:
@ -106,6 +106,9 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
!segment.deleted_at && segment.type === 'default'
|
!segment.deleted_at && segment.type === 'default'
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
getLabel: function (segment) {
|
||||||
|
return segment.name + ' (' + segment.subscribers + ')';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,6 +140,9 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
!segment.deleted_at && segment.type === 'default'
|
!segment.deleted_at && segment.type === 'default'
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
getLabel: function (segment) {
|
||||||
|
return segment.name + ' (' + segment.subscribers + ')';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,6 +174,9 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
segment.type === 'default'
|
segment.type === 'default'
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
getLabel: function (segment) {
|
||||||
|
return segment.name + ' (' + segment.subscribers + ')';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ class Menu {
|
|||||||
? (int)$listing_per_page
|
? (int)$listing_per_page
|
||||||
: Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
: Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
||||||
|
|
||||||
$data['segments'] = Segment::findArray();
|
$data['segments'] = Segment::getSegmentsWithSubscriberCount();
|
||||||
|
|
||||||
$data['custom_fields'] = array_map(function($field) {
|
$data['custom_fields'] = array_map(function($field) {
|
||||||
$field['params'] = unserialize($field['params']);
|
$field['params'] = unserialize($field['params']);
|
||||||
|
@ -126,18 +126,19 @@ 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'))
|
||||||
->select_expr(
|
->selectExpr(
|
||||||
'COUNT('.MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id)', 'subscribers'
|
self::$_table.'.*, COUNT('.MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id) `subscribers`'
|
||||||
)
|
)
|
||||||
->left_outer_join(
|
->leftOuterJoin(
|
||||||
MP_SUBSCRIBER_SEGMENT_TABLE,
|
MP_SUBSCRIBER_SEGMENT_TABLE,
|
||||||
array(self::$_table.'.id', '=', MP_SUBSCRIBER_SEGMENT_TABLE.'.segment_id'))
|
array(self::$_table.'.id', '=', MP_SUBSCRIBER_SEGMENT_TABLE.'.segment_id'))
|
||||||
->left_outer_join(
|
->leftOuterJoin(
|
||||||
MP_SUBSCRIBERS_TABLE,
|
MP_SUBSCRIBERS_TABLE,
|
||||||
array(MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id', '=', MP_SUBSCRIBERS_TABLE.'.id'))
|
array(MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id', '=', MP_SUBSCRIBERS_TABLE.'.id'))
|
||||||
->whereNull(MP_SUBSCRIBERS_TABLE.'.deleted_at')
|
->whereNull(MP_SUBSCRIBERS_TABLE.'.deleted_at')
|
||||||
->group_by(self::$_table.'.id')
|
->groupBy(self::$_table.'.id')
|
||||||
->group_by(self::$_table.'.name')
|
->groupBy(self::$_table.'.name')
|
||||||
|
->orderByAsc(self::$_table.'.name')
|
||||||
->where(self::$_table.'.type', 'default')
|
->where(self::$_table.'.type', 'default')
|
||||||
->whereNull(self::$_table.'.deleted_at')
|
->whereNull(self::$_table.'.deleted_at')
|
||||||
->findArray();
|
->findArray();
|
||||||
|
Reference in New Issue
Block a user