2575e10ec4
refs https://github.com/TryGhost/Team/issues/1505 refs https://github.com/TryGhost/Team/issues/1466 This gives us historic data for subscriptions broken down by tier and cadence * Cleaned up tests Fixed up usage of knex, making sure to destroy the connection after tests * Removed Node 12 from testing matrix Get outta my pub!
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
const MRRService = require('./mrr');
|
|
const MembersService = require('./members');
|
|
const SubscriptionStatsService = require('./subscriptions');
|
|
|
|
class StatsService {
|
|
/**
|
|
* @param {object} deps
|
|
* @param {MRRService} deps.mrr
|
|
* @param {MembersService} deps.members
|
|
* @param {SubscriptionStatsService} deps.subscriptions
|
|
**/
|
|
constructor(deps) {
|
|
this.mrr = deps.mrr;
|
|
this.members = deps.members;
|
|
this.subscriptions = deps.subscriptions;
|
|
}
|
|
|
|
async getMRRHistory() {
|
|
return this.mrr.getHistory();
|
|
}
|
|
|
|
async getMemberCountHistory() {
|
|
return this.members.getCountHistory();
|
|
}
|
|
|
|
async getSubscriptionCountHistory() {
|
|
return this.subscriptions.getSubscriptionHistory();
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = StatsService;
|