refactor(core): Move tag collection into repository (no-changelog) (#6860)

* refactor(core): Move tag collection into repository

* Fix tests

* Address feedback

* Fix missing spot
This commit is contained in:
Iván Ovejero
2023-08-08 14:08:56 +02:00
committed by GitHub
parent 8de28fe4d0
commit 11440bfd3c
15 changed files with 59 additions and 61 deletions

View File

@@ -26,6 +26,7 @@ import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
import { In } from 'typeorm';
import type { SourceControlledFile } from './types/sourceControlledFile';
import { VariablesService } from '../variables/variables.service';
import { TagRepository } from '@/databases/repositories';
@Service()
export class SourceControlExportService {
@@ -35,7 +36,10 @@ export class SourceControlExportService {
private credentialExportFolder: string;
constructor(private readonly variablesService: VariablesService) {
constructor(
private readonly variablesService: VariablesService,
private readonly tagRepository: TagRepository,
) {
const userFolder = UserSettings.getUserN8nFolderPath();
this.gitFolder = path.join(userFolder, SOURCE_CONTROL_GIT_FOLDER);
this.workflowExportFolder = path.join(this.gitFolder, SOURCE_CONTROL_WORKFLOW_EXPORT_FOLDER);
@@ -167,7 +171,7 @@ export class SourceControlExportService {
async exportTagsToWorkFolder(): Promise<ExportResult> {
try {
sourceControlFoldersExistCheck([this.gitFolder]);
const tags = await Db.collections.Tag.find();
const tags = await this.tagRepository.find();
// do not export empty tags
if (tags.length === 0) {
return {