refactor(core): Switch Tags queries from QueryBuilder to Repository API (no-changelog) (#5819)

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-30 16:25:51 +02:00
committed by GitHub
parent f8f584c136
commit 41cdee7bc7
9 changed files with 58 additions and 81 deletions

View File

@@ -1,8 +1,9 @@
import { Column, Entity, Generated, Index, ManyToMany, PrimaryColumn } from 'typeorm';
import { Column, Entity, Generated, Index, ManyToMany, OneToMany, PrimaryColumn } from 'typeorm';
import { IsString, Length } from 'class-validator';
import { idStringifier } from '../utils/transformers';
import type { WorkflowEntity } from './WorkflowEntity';
import type { WorkflowTagMapping } from './WorkflowTagMapping';
import { AbstractEntity } from './AbstractEntity';
@Entity()
@@ -19,4 +20,7 @@ export class TagEntity extends AbstractEntity {
@ManyToMany('WorkflowEntity', 'tags')
workflows: WorkflowEntity[];
@OneToMany('WorkflowTagMapping', 'tags')
workflowMappings: WorkflowTagMapping[];
}

View File

@@ -19,6 +19,7 @@ import config from '@/config';
import type { TagEntity } from './TagEntity';
import type { SharedWorkflow } from './SharedWorkflow';
import type { WorkflowStatistics } from './WorkflowStatistics';
import type { WorkflowTagMapping } from './WorkflowTagMapping';
import { idStringifier, objectRetriever, sqlite } from '../utils/transformers';
import { AbstractEntity, jsonColumnType } from './AbstractEntity';
import type { IWorkflowDb } from '@/Interfaces';
@@ -73,6 +74,9 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
})
tags?: TagEntity[];
@OneToMany('WorkflowTagMapping', 'workflows')
tagMappings: WorkflowTagMapping[];
@OneToMany('SharedWorkflow', 'workflow')
shared: SharedWorkflow[];

View File

@@ -0,0 +1,21 @@
import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
import { idStringifier } from '../utils/transformers';
import type { TagEntity } from './TagEntity';
import type { WorkflowEntity } from './WorkflowEntity';
@Entity({ name: 'workflows_tags' })
export class WorkflowTagMapping {
@PrimaryColumn({ transformer: idStringifier })
workflowId: string;
@ManyToOne('WorkflowEntity', 'tagMappings')
@JoinColumn({ name: 'workflowId' })
workflows: WorkflowEntity[];
@PrimaryColumn()
tagId: string;
@ManyToOne('TagEntity', 'workflowMappings')
@JoinColumn({ name: 'tagId' })
tags: TagEntity[];
}

View File

@@ -14,6 +14,7 @@ import { TagEntity } from './TagEntity';
import { User } from './User';
import { WebhookEntity } from './WebhookEntity';
import { WorkflowEntity } from './WorkflowEntity';
import { WorkflowTagMapping } from './WorkflowTagMapping';
import { WorkflowStatistics } from './WorkflowStatistics';
import { ExecutionMetadata } from './ExecutionMetadata';
@@ -33,6 +34,7 @@ export const entities = {
User,
WebhookEntity,
WorkflowEntity,
WorkflowTagMapping,
WorkflowStatistics,
ExecutionMetadata,
};