refactor: database types (#17468)

This commit is contained in:
Jason Rasmussen
2025-04-08 12:40:03 -04:00
committed by GitHub
parent ac65d46ec6
commit 4794eeca88
9 changed files with 44 additions and 39 deletions

View File

@@ -1,15 +1,15 @@
import { Tag } from 'src/database';
import { TagRepository } from 'src/repositories/tag.repository';
import { TagItem } from 'src/types';
type UpsertRequest = { userId: string; tags: string[] };
export const upsertTags = async (repository: TagRepository, { userId, tags }: UpsertRequest) => {
tags = [...new Set(tags)];
const results: TagItem[] = [];
const results: Tag[] = [];
for (const tag of tags) {
const parts = tag.split('/').filter(Boolean);
let parent: TagItem | undefined;
let parent: Tag | undefined;
for (const part of parts) {
const value = parent ? `${parent.value}/${part}` : part;