fix(analytics): accessing analytics in report

This commit is contained in:
Karol Sójko 2022-12-20 14:13:48 +01:00
parent 8a0fbb28b0
commit ef26dc8cbb
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
2 changed files with 2 additions and 11 deletions

View file

@ -29,7 +29,6 @@ const requestReport = async (
calculateMonthlyRecurringRevenue: CalculateMonthlyRecurringRevenue,
timer: TimerInterface,
adminEmails: string[],
logger: Logger,
): Promise<void> => {
await calculateMonthlyRecurringRevenue.execute({})
@ -134,7 +133,6 @@ const requestReport = async (
counts: await statisticsStore.calculateTotalCountOverPeriod(statisticName, Period.Last30DaysIncludingToday),
})
}
logger.info('Calculated thirty days statistics: %O', statisticsOverTime)
const monthlyStatisticsNames = [StatisticMeasureName.NAMES.MRR]
for (const statisticName of monthlyStatisticsNames) {
@ -284,7 +282,6 @@ void container.load().then((container) => {
calculateMonthlyRecurringRevenue,
timer,
adminEmails,
logger,
),
)
.then(() => {

View file

@ -6,24 +6,18 @@ import { StatisticMeasureName } from '../Statistics/StatisticMeasureName'
import { Period } from '../Time/Period'
const countActiveUsers = (measureName: string, data: any): { yesterday: number; last30Days: number } => {
const totalActiveUsersLast30DaysIncludingToday = data.statisticMeasures.find(
const totalActiveUsersLast30DaysIncludingToday = data.statisticsOverTime.find(
(a: { name: string; period: number }) => a.name === measureName && a.period === 27,
)
// eslint-disable-next-line no-console
console.log(totalActiveUsersLast30DaysIncludingToday)
const totalActiveUsersYesterday =
totalActiveUsersLast30DaysIncludingToday.counts[totalActiveUsersLast30DaysIncludingToday.counts.length - 2]
.totalCount
// eslint-disable-next-line no-console
console.log(totalActiveUsersYesterday)
const filteredCounts = totalActiveUsersLast30DaysIncludingToday.counts.filter(
(count: { totalCount: number }) => count.totalCount !== 0,
)
// eslint-disable-next-line no-console
console.log(filteredCounts)
const averageActiveUsersLast30Days = Math.floor(
filteredCounts.reduce((previousValue: { totalCount: any }, currentValue: { totalCount: any }) => {
return previousValue.totalCount + currentValue.totalCount