fix(auth): add persisting statistics for all subscription plans

This commit is contained in:
Karol Sójko
2022-12-20 08:45:43 +01:00
parent 2ea17b2dea
commit addedb3091
5 changed files with 56 additions and 5 deletions
@@ -1,4 +1,4 @@
import { MapperInterface, Uuid } from '@standardnotes/domain-core'
import { MapperInterface, SubscriptionPlanName, Uuid } from '@standardnotes/domain-core'
import { Repository } from 'typeorm'
import { SessionTrace } from '../../Domain/Session/SessionTrace'
import { SessionTraceRepositoryInterface } from '../../Domain/Session/SessionTraceRepositoryInterface'
@@ -10,6 +10,18 @@ export class MySQLSessionTraceRepository implements SessionTraceRepositoryInterf
private mapper: MapperInterface<SessionTrace, TypeORMSessionTrace>,
) {}
async countByDateAndSubscriptionPlanName(date: Date, subscriptionPlanName: SubscriptionPlanName): Promise<number> {
return this.ormRepository
.createQueryBuilder('trace')
.where('trace.creation_date = :creationDate', {
creationDate: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
})
.andWhere('trace.subscription_plan_name = :subscriptionPlanName', {
subscriptionPlanName: subscriptionPlanName.value,
})
.getCount()
}
async countByDate(date: Date): Promise<number> {
return this.ormRepository
.createQueryBuilder('trace')