fix(core): Remove circular dependency in WorkflowService and ActiveWorkflowRunner (#8128)
## Summary A circular dependency between `WorkflowService` and `ActiveWorkflowRunner` is sometimes causing `this.activeWorkflowRunner` to be `undefined` in `WorkflowService`. Breaking this circular dependency should hopefully fix this issue. ## Related tickets and issues #8122 ## Review / Merge checklist - [x] PR title and summary are descriptive - [ ] Tests included
This commit is contained in:
committed by
GitHub
parent
e9c7fd7397
commit
21788d9153
@@ -1,5 +1,6 @@
|
||||
import { Service } from 'typedi';
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { DataSource, Repository, type UpdateResult, type FindOptionsWhere } from 'typeorm';
|
||||
import config from '@/config';
|
||||
import { WorkflowEntity } from '../entities/WorkflowEntity';
|
||||
|
||||
@Service()
|
||||
@@ -8,6 +9,13 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||
super(WorkflowEntity, dataSource.manager);
|
||||
}
|
||||
|
||||
async get(where: FindOptionsWhere<WorkflowEntity>, options?: { relations: string[] }) {
|
||||
return this.findOne({
|
||||
where,
|
||||
relations: options?.relations,
|
||||
});
|
||||
}
|
||||
|
||||
async getAllActive() {
|
||||
return this.find({
|
||||
where: { active: true },
|
||||
@@ -28,4 +36,21 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||
});
|
||||
return totalTriggerCount ?? 0;
|
||||
}
|
||||
|
||||
async updateWorkflowTriggerCount(id: string, triggerCount: number): Promise<UpdateResult> {
|
||||
const qb = this.createQueryBuilder('workflow');
|
||||
return qb
|
||||
.update()
|
||||
.set({
|
||||
triggerCount,
|
||||
updatedAt: () => {
|
||||
if (['mysqldb', 'mariadb'].includes(config.getEnv('database.type'))) {
|
||||
return 'updatedAt';
|
||||
}
|
||||
return '"updatedAt"';
|
||||
},
|
||||
})
|
||||
.where('id = :id', { id })
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user