refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8186)

Follow-up to: #8163
This commit is contained in:
Iván Ovejero
2024-01-02 17:53:24 +01:00
committed by GitHub
parent 0ca2759d75
commit 40c1eeeddd
35 changed files with 341 additions and 354 deletions

View File

@@ -1,6 +1,4 @@
import { flags } from '@oclif/command';
import type { FindOptionsWhere } from 'typeorm';
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { BaseCommand } from '../BaseCommand';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import Container from 'typedi';
@@ -32,12 +30,13 @@ export class ListWorkflowCommand extends BaseCommand {
this.error('The --active flag has to be passed using true or false');
}
const findQuery: FindOptionsWhere<WorkflowEntity> = {};
if (flags.active !== undefined) {
findQuery.active = flags.active === 'true';
}
const workflowRepository = Container.get(WorkflowRepository);
const workflows =
flags.active !== undefined
? await workflowRepository.findByActiveState(flags.active === 'true')
: await workflowRepository.find();
const workflows = await Container.get(WorkflowRepository).findBy(findQuery);
if (flags.onlyId) {
workflows.forEach((workflow) => this.logger.info(workflow.id));
} else {