mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
32 lines
926 B
JavaScript
32 lines
926 B
JavaScript
|
import Component from '@glimmer/component';
|
||
|
import {inject as service} from '@ember/service';
|
||
|
import {task, taskGroup} from 'ember-concurrency-decorators';
|
||
|
import {tracked} from '@glimmer/tracking';
|
||
|
|
||
|
export default class GhMembersSegmentCountComponent extends Component {
|
||
|
@service store;
|
||
|
|
||
|
@tracked total = 0;
|
||
|
@tracked segmentTotal = 0;
|
||
|
|
||
|
@taskGroup fetchTasks;
|
||
|
|
||
|
@task({group: 'fetchTasks'})
|
||
|
*fetchTotalsTask() {
|
||
|
this.fetchSegmentTotalTask.perform();
|
||
|
|
||
|
const members = yield this.store.query('member', {limit: 1});
|
||
|
this.total = members.meta.pagination.total;
|
||
|
}
|
||
|
|
||
|
@task({group: 'fetchTasks'})
|
||
|
*fetchSegmentTotalTask() {
|
||
|
if (!this.args.segment) {
|
||
|
return this.segmentTotal = 0;
|
||
|
}
|
||
|
|
||
|
const members = yield this.store.query('member', {limit: 1, filter: this.args.segment});
|
||
|
this.segmentTotal = members.meta.pagination.total;
|
||
|
}
|
||
|
}
|