refactor(core): Move typeorm operators from various sources into repositories (no-changelog) (#8174)

Follow-up to: #8165
This commit is contained in:
Iván Ovejero
2023-12-28 13:14:10 +01:00
committed by GitHub
parent 405e26757e
commit e418d42450
17 changed files with 185 additions and 209 deletions

View File

@@ -17,6 +17,7 @@ import { isStringArray } from '@/utils';
import config from '@/config';
import { WorkflowEntity } from '../entities/WorkflowEntity';
import { SharedWorkflow } from '../entities/SharedWorkflow';
import { WebhookEntity } from '../entities/WebhookEntity';
@Service()
export class WorkflowRepository extends Repository<WorkflowEntity> {
@@ -183,4 +184,18 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
where: { name: Like(`${workflowName}%`) },
});
}
async findIn(workflowIds: string[]) {
return this.find({
select: ['id', 'name'],
where: { id: In(workflowIds) },
});
}
async findWebhookBasedActiveWorkflows() {
return this.createQueryBuilder('workflow')
.select('DISTINCT workflow.id, workflow.name')
.innerJoin(WebhookEntity, 'webhook_entity', 'workflow.id = webhook_entity.workflowId')
.execute() as Promise<Array<{ id: string; name: string }>>;
}
}