mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
b048b02f67
closes https://github.com/TryGhost/Team/issues/1939 - adds new endpoint that returns count of referrer sources by date for admin dashboard
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
const MRRService = require('./mrr');
|
|
const MembersService = require('./members');
|
|
const SubscriptionStatsService = require('./subscriptions');
|
|
const ReferrersStatsService = require('./referrers');
|
|
|
|
class StatsService {
|
|
/**
|
|
* @param {object} deps
|
|
* @param {MRRService} deps.mrr
|
|
* @param {MembersService} deps.members
|
|
* @param {SubscriptionStatsService} deps.subscriptions
|
|
* @param {ReferrersStatsService} deps.referrers
|
|
**/
|
|
constructor(deps) {
|
|
this.mrr = deps.mrr;
|
|
this.members = deps.members;
|
|
this.subscriptions = deps.subscriptions;
|
|
this.referrers = deps.referrers;
|
|
}
|
|
|
|
async getMRRHistory() {
|
|
return this.mrr.getHistory();
|
|
}
|
|
|
|
async getMemberCountHistory() {
|
|
return this.members.getCountHistory();
|
|
}
|
|
|
|
async getSubscriptionCountHistory() {
|
|
return this.subscriptions.getSubscriptionHistory();
|
|
}
|
|
|
|
async getReferrersHistory() {
|
|
return this.referrers.getReferrersHistory();
|
|
}
|
|
|
|
/**
|
|
* @param {string} postId
|
|
*/
|
|
async getPostReferrers(postId) {
|
|
return {
|
|
data: await this.referrers.getForPost(postId),
|
|
meta: {}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param {object} deps
|
|
* @param {import('knex').Knex} deps.knex
|
|
*
|
|
* @returns {StatsService}
|
|
**/
|
|
static create(deps) {
|
|
return new StatsService({
|
|
mrr: new MRRService(deps),
|
|
members: new MembersService(deps),
|
|
subscriptions: new SubscriptionStatsService(deps),
|
|
referrers: new ReferrersStatsService(deps)
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = StatsService;
|