refactor(core): Upgrade typeorm (no-changelog) (#5423)

[Now we can use aggregate functions directly over the repository API](https://github.com/typeorm/typeorm/pull/9737)
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-02-09 10:44:07 +01:00
committed by GitHub
parent e0c4c25227
commit 52cb185637
3 changed files with 79 additions and 67 deletions

View File

@@ -4,14 +4,8 @@ import * as Db from '@/Db';
export class LicenseService {
static async getActiveTriggerCount(): Promise<number> {
const qb = Db.collections.Workflow.createQueryBuilder('workflow')
.select('SUM(workflow.triggerCount)', 'triggerCount')
.where('workflow.active = :active', { active: true });
const results: { triggerCount: number } | undefined = await qb.getRawOne();
if (!results) {
throw new Error('Could not get active trigger count');
}
return results.triggerCount ?? 0;
const totalTriggerCount = await Db.collections.Workflow.sum('triggerCount', { active: true });
return totalTriggerCount ?? 0;
}
// Helper for getting the basic license data that we want to return