Skip to content

Commit 72dacaa

Browse files
cleanup
1 parent 6ae0402 commit 72dacaa

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

open-api/typescript-sdk/src/fetch-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@ export type TagBulkAssetsResponseDto = {
14061406
};
14071407
export type TagUpdateDto = {
14081408
color?: string | null;
1409+
name?: string;
14091410
};
14101411
export type TimeBucketResponseDto = {
14111412
count: number;

server/src/repositories/tag.repository.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class TagRepository {
7777
if (dto.value) {
7878
// propagate value update downstream
7979
const descendantIds = await this.getDescendantIds(id);
80-
const descendants = await this.getMany(descendantIds.filter(_id => _id !== id));
81-
const childrenByParentId = new Map<string, { id: string, value: string }[]>();
80+
const descendants = await this.getMany(descendantIds.filter((_id) => _id !== id));
81+
const childrenByParentId = new Map<string, { id: string; value: string }[]>();
8282
for (const descendant of descendants) {
8383
const parentId = descendant.parentId;
8484
if (parentId) {
@@ -89,7 +89,7 @@ export class TagRepository {
8989
}
9090
}
9191

92-
const queue: { id: string; value: string }[] = [{id, value: updated.value}];
92+
const queue: { id: string; value: string }[] = [{ id, value: updated.value }];
9393
for (let i = 0; i < queue.length; i++) {
9494
const { id, value } = queue[i];
9595
const children = childrenByParentId.get(id) ?? [];
@@ -98,26 +98,26 @@ export class TagRepository {
9898
const item = { id: child.id, value: `${value}/${name}` };
9999
queue.push(item);
100100
}
101-
}
101+
}
102102

103-
const toUpdate = queue.slice(1);
104-
if (toUpdate.length > 0) {
105-
await sql`
103+
const toUpdate = queue.slice(1);
104+
if (toUpdate.length > 0) {
105+
await sql`
106106
UPDATE tags
107107
SET value = updates.value
108108
FROM (
109109
VALUES
110110
${sql.join(
111-
toUpdate.map(u => sql`(${sql`${u.id}::uuid`}, ${u.value})`),
112-
sql`, `
111+
toUpdate.map((u) => sql`(${sql`${u.id}::uuid`}, ${u.value})`),
112+
sql`, `,
113113
)}
114114
) AS updates(id, value)
115115
WHERE tags.id = updates.id
116116
`.execute(tx);
117-
};
117+
}
118118
}
119119
});
120-
120+
121121
return updated!;
122122
}
123123

@@ -232,10 +232,10 @@ export class TagRepository {
232232
.where('id_ancestor', '=', ancestorId)
233233
.execute();
234234

235-
return results.map(r => r.id_descendant);
235+
return results.map((r) => r.id_descendant);
236236
}
237237

238-
async updateTagClosures(tag: { id: string, parentId?: string | null }, tx: Transaction<DB>) {
238+
async updateTagClosures(tag: { id: string; parentId?: string | null }, tx: Transaction<DB>) {
239239
// update closure table
240240
await tx
241241
.insertInto('tags_closure')

server/src/services/tag.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ describe(TagService.name, () => {
113113
it('should update a tag', async () => {
114114
mocks.access.tag.checkOwnerAccess.mockResolvedValue(new Set(['tag-1']));
115115
mocks.tag.update.mockResolvedValue(tagStub.colorCreate);
116+
mocks.tag.getOne.mockResolvedValue(tagStub.tag);
116117
await expect(sut.update(authStub.admin, 'tag-1', { color: '#000000' })).resolves.toEqual(tagResponseStub.color1);
117118
expect(mocks.tag.update).toHaveBeenCalledWith('tag-1', { color: '#000000' });
118119
});

server/src/services/tag.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export class TagService extends BaseService {
6868

6969
let value;
7070
if (name) {
71-
const parts = existing.value.split("/");
71+
const parts = existing.value.split('/');
7272
parts[parts.length - 1] = name;
73-
value = parts.join("/");
73+
value = parts.join('/');
7474
}
7575

7676
const tag = await this.tagRepository.update(id, { value, color });

0 commit comments

Comments
 (0)