Ghost/core/server/api/canary/stats.js
Simon Backx ae54352a29
Created new stats service and stats API to get member count history (#14391)
refs TryGhost/Team#1458
refs TryGhost/Team#1459
refs TryGhost/Team#1372

- Added a new stats service, which is divided into several categories. Currently only the 'members' category for member related stats.
- When there are missing or corrupt members status events in the DB, the totals returned by the old member stats endpoint (`/members/stats/count`) were wrong. This is fixed in the new service by counting in reverse order and starting with the actual totals.
- New Stats API, with the new `/stats/members/count-history` endpoint.
- This new endpoint also returns the paid deltas -> dashboard 5.0 will show subscribed and canceled paid members for each day
- Includes tests for the new stats service and endpoint
2022-03-31 16:01:11 +02:00

15 lines
325 B
JavaScript

const statsService = require('../../services/stats');
module.exports = {
docName: 'stats',
memberCountHistory: {
permissions: {
docName: 'members',
method: 'browse'
},
async query() {
return await statsService.members.getCountHistory();
}
}
};