refactor: Trim down the response on the Workflows listing endpoint (#4726)

* fix: Avoid hashing workflows in the listing page

* stop returning full nodes data on the listings page when sharing is enabled

* fix the relations array for workflow listing

* add a comment explaining the hash skipping hack
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-25 14:20:28 +01:00
committed by GitHub
parent 39a5dc57a8
commit 1579d05fd1
4 changed files with 32 additions and 32 deletions

View File

@@ -140,26 +140,27 @@ export class WorkflowsService {
}
const fields: Array<keyof WorkflowEntity> = ['id', 'name', 'active', 'createdAt', 'updatedAt'];
const relations: string[] = [];
const query: FindManyOptions<WorkflowEntity> = {
select: config.get('enterprise.features.sharing') ? [...fields, 'nodes'] : fields,
relations: config.get('enterprise.features.sharing')
? ['tags', 'shared', 'shared.user', 'shared.role']
: ['tags'],
};
if (config.getEnv('workflowTagsDisabled')) {
delete query.relations;
if (!config.getEnv('workflowTagsDisabled')) {
relations.push('tags');
}
const workflows = await Db.collections.Workflow.find(
Object.assign(query, {
where: {
id: In(sharedWorkflowIds),
...filter,
},
}),
);
const isSharingEnabled = config.getEnv('enterprise.features.sharing');
if (isSharingEnabled) {
relations.push('shared', 'shared.user', 'shared.role');
}
const query: FindManyOptions<WorkflowEntity> = {
select: isSharingEnabled ? [...fields, 'nodes'] : fields,
relations,
where: {
id: In(sharedWorkflowIds),
...filter,
},
};
const workflows = await Db.collections.Workflow.find(query);
return workflows.map((workflow) => {
const { id, ...rest } = workflow;