@standardnotes/analytics
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -13,2 +13,3 @@ import { Period } from '../Time/Period'; | ||
}>>; | ||
calculateActivityTotalCountOverTime(activity: AnalyticsActivity, period: Period): Promise<number>; | ||
} |
@@ -10,2 +10,3 @@ import * as IORedis from 'ioredis'; | ||
constructor(periodKeyGenerator: PeriodKeyGeneratorInterface, redisClient: IORedis.Redis); | ||
calculateActivityTotalCountOverTime(activity: AnalyticsActivity, period: Period): Promise<number>; | ||
calculateActivityChangesTotalCount(activity: AnalyticsActivity, period: Period): Promise<Array<{ | ||
@@ -12,0 +13,0 @@ periodKey: string; |
@@ -12,2 +12,16 @@ "use strict"; | ||
} | ||
async calculateActivityTotalCountOverTime(activity, period) { | ||
if (period !== Period_1.Period.Last30Days) { | ||
throw new Error(`Unsuporrted period: ${period}`); | ||
} | ||
const periodKeys = this.periodKeyGenerator.getDiscretePeriodKeys(Period_1.Period.Last30Days); | ||
let previousPeriodKey = periodKeys[0]; | ||
let intersectionPeriodKey = null; | ||
for (let i = 0; i < periodKeys.length - 1; i++) { | ||
intersectionPeriodKey = `${periodKeys[0]}-iteration-${i}`; | ||
await this.redisClient.bitop('AND', `bitmap:action:${activity}:timespan:${intersectionPeriodKey}`, `bitmap:action:${activity}:timespan:${previousPeriodKey}`, `bitmap:action:${activity}:timespan:${periodKeys[i + 1]}`); | ||
previousPeriodKey = intersectionPeriodKey; | ||
} | ||
return this.redisClient.bitcount(`bitmap:action:${activity}:timespan:${intersectionPeriodKey}`); | ||
} | ||
async calculateActivityChangesTotalCount(activity, period) { | ||
@@ -14,0 +28,0 @@ if (period !== Period_1.Period.Last30Days) { |
{ | ||
"name": "@standardnotes/analytics", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"engines": { | ||
@@ -40,3 +40,3 @@ "node": ">=14.0.0 <17.0.0" | ||
}, | ||
"gitHead": "a04ab5b0e8afae29be843034bc07357d824c04a8" | ||
"gitHead": "becb386d1012b9fd33fbb143614497f899cfc10e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56886
442