fix(analytics): add monthly mrr to the report

This commit is contained in:
Karol Sójko 2022-11-10 11:52:19 +01:00
parent 92ba682198
commit fce47a0a37
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
2 changed files with 19 additions and 3 deletions

View file

@ -100,8 +100,6 @@ const requestReport = async (
})
}
const thirtyDaysStatisticsNames = [StatisticsMeasure.MRR]
const statisticsOverTime: Array<{
name: string
period: number
@ -110,6 +108,8 @@ const requestReport = async (
totalCount: number
}>
}> = []
const thirtyDaysStatisticsNames = [StatisticsMeasure.MRR]
for (const statisticName of thirtyDaysStatisticsNames) {
statisticsOverTime.push({
name: statisticName,
@ -118,6 +118,15 @@ const requestReport = async (
})
}
const monthlyStatisticsNames = [StatisticsMeasure.MRR]
for (const statisticName of monthlyStatisticsNames) {
statisticsOverTime.push({
name: statisticName,
period: Period.ThisYear,
counts: await statisticsStore.calculateTotalCountOverPeriod(statisticName, Period.ThisYear),
})
}
const statisticMeasureNames = [
StatisticsMeasure.Income,
StatisticsMeasure.PlusSubscriptionInitialAnnualPaymentsIncome,

View file

@ -14,7 +14,14 @@ export class RedisStatisticsStore implements StatisticsStoreInterface {
period: Period,
): Promise<{ periodKey: string; totalCount: number }[]> {
if (
![Period.Last30Days, Period.Q1ThisYear, Period.Q2ThisYear, Period.Q3ThisYear, Period.Q4ThisYear].includes(period)
![
Period.Last30Days,
Period.ThisYear,
Period.Q1ThisYear,
Period.Q2ThisYear,
Period.Q3ThisYear,
Period.Q4ThisYear,
].includes(period)
) {
throw new Error(`Unsuporrted period: ${period}`)
}