Skip to content

Commit

Permalink
refactor(core): Upgrade typeorm (no-changelog)
Browse files Browse the repository at this point in the history
[Now we can use aggregate functions directly over the repository API](typeorm/typeorm#9737)
  • Loading branch information
netroy committed Feb 8, 2023
1 parent 94f2b2a commit 1c6a3cb
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 65 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"sse-channel": "^4.0.0",
"swagger-ui-express": "^4.3.0",
"syslog-client": "^1.1.1",
"typeorm": "0.3.11",
"typeorm": "^0.3.12",
"uuid": "^8.3.2",
"validator": "13.7.0",
"winston": "^3.3.3",
Expand Down
9 changes: 3 additions & 6 deletions packages/cli/src/license/License.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ 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) {
const totalTriggerCount = await Db.collections.Workflow.sum('triggerCount', { active: true });
if (!totalTriggerCount) {
throw new Error('Could not get active trigger count');
}
return results.triggerCount ?? 0;
return totalTriggerCount;
}

// Helper for getting the basic license data that we want to return
Expand Down
Loading

0 comments on commit 1c6a3cb

Please sign in to comment.