mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
104f84f252
As discussed with the product team we want to enforce kebab-case file names for all files, with the exception of files which export a single class, in which case they should be PascalCase and reflect the class which they export. This will help find classes faster, and should push better naming for them too. Some files and packages have been excluded from this linting, specifically when a library or framework depends on the naming of a file for the functionality e.g. Ember, knex-migrator, adapter-manager
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
const MRRService = require('./MrrStatsService');
|
|
const MembersService = require('./MembersStatsService');
|
|
const SubscriptionStatsService = require('./SubscriptionStatsService');
|
|
const ReferrersStatsService = require('./ReferrersStatsService');
|
|
|
|
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;
|