mirror of
https://github.com/standardnotes/server
synced 2026-10-15 15:13:39 -04:00
fix(analytics): accessing analytics in report
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user