Skip to content

Commit e924996

Browse files
chore: trace db rule retrieval
1 parent af5daa0 commit e924996

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/event-queue/src/release-targets/evaluate/version-manager.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type * as schema from "@ctrlplane/db/schema";
12
import type { FullReleaseTarget } from "@ctrlplane/events";
23
import type { ReleaseManager } from "@ctrlplane/rule-engine";
34
import { isPresent } from "ts-is-present";
@@ -107,6 +108,13 @@ export class VersionManager implements ReleaseManager {
107108
return new Set<string>(policyTargets.map((pt) => pt.policyId));
108109
}
109110

111+
@Trace()
112+
private async getRules(policies: schema.Policy[]) {
113+
return Promise.all(
114+
policies.map((p) => this.rules.getRules(p.id, this.releaseTarget.id)),
115+
).then((rules) => rules.flat());
116+
}
117+
110118
@Trace()
111119
async evaluate() {
112120
const policyIds = await this.getPoliciesIds();
@@ -115,9 +123,7 @@ export class VersionManager implements ReleaseManager {
115123
.filter((p) => p.enabled)
116124
.filter((p) => policyIds.has(p.id));
117125

118-
const policyRules = await Promise.all(
119-
policies.map((p) => this.rules.getRules(p.id, this.releaseTarget.id)),
120-
).then((rules) => rules.flat());
126+
const policyRules = await this.getRules(policies);
121127
const versions = await this.findVersionsForEvaluation(policyIds);
122128
return new VersionRuleEngine(policyRules).evaluate(versions);
123129
}

0 commit comments

Comments
 (0)