mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
feat(analytics): add calculating monthly recurring revenue
This commit is contained in:
@@ -17,6 +17,19 @@ export class MySQLRevenueModificationRepository implements RevenueModificationRe
|
||||
private revenueModificationMap: MapInterface<RevenueModification, TypeORMRevenueModification>,
|
||||
) {}
|
||||
|
||||
async sumMRRDiff(): Promise<number> {
|
||||
const result = await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.select('sum(new_mrr - previous_mrr)', 'mrrDiff')
|
||||
.getRawOne()
|
||||
|
||||
if (result === undefined) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return +(+result.mrrDiff).toFixed(2)
|
||||
}
|
||||
|
||||
async findLastByUserUuid(userUuid: Uuid): Promise<RevenueModification | null> {
|
||||
const persistence = await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
|
||||
Reference in New Issue
Block a user