Skip to content

Commit 44dfd9f

Browse files
committed
refactor: Rename removeLabel/Category functions to delete for consistency
1 parent 9e48d87 commit 44dfd9f

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

src/server/api/set-labels.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-12-08 17:43:05
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-05-06 19:12:28
7+
* Last Modified: 2026-05-06 19:55:37
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -52,8 +52,8 @@ export default defineEventHandler(async (event): Promise<ApiResponse<void>> => {
5252
return await getApiResponse<void>(async () => {
5353
await upsertLabelCategories(updatedCategories);
5454
await upsertLabels(updatedLabels);
55-
await removeLabels(deletedLabels.flatMap((e) => e.id));
56-
await removeLabelCategories(deletedCategories.flatMap((e) => e.id));
55+
await deleteLabels(deletedLabels.flatMap((e) => e.id));
56+
await deleteLabelCategories(deletedCategories.flatMap((e) => e.id));
5757
});
5858

5959
});

src/server/utils/jobs/dataCleanup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-12-30 22:18:23
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-04-01 18:38:13
7+
* Last Modified: 2026-05-06 19:54:55
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -17,7 +17,7 @@
1717

1818
import { getClothes, upsertClothing } from "~/server/utils/useClothesDb";
1919
import { deleteImage, getAllImagePaths, imgCategory } from "~/server/utils/useImagesStorage";
20-
import { getAllLabelCategories, getAllLabels, removeLabels } from "~/server/utils/useLabelsDb";
20+
import { getAllLabelCategories, getAllLabels, deleteLabels } from "~/server/utils/useLabelsDb";
2121
import { getOutfit, upsertOutfit } from "~/server/utils/useOutfitsDb";
2222
import type { Clothing } from "~/model/item";
2323
import type { Outfit } from "~/model/item";
@@ -93,7 +93,7 @@ export default {
9393
});
9494

9595
console.debug("DEBUG - dataCleanup: Unreferenced labels: ", labelIDsToRemove);
96-
removeLabels(labelIDsToRemove);
96+
deleteLabels(labelIDsToRemove);
9797

9898

9999
// Filter clothes for non existent labels // TODO: Not (yet) in separate function due to amount of in/out params

src/server/utils/useLabelsDb.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Created Date: 2025-12-06 17:28:44
55
* Author: 3urobeat
66
*
7-
* Last Modified: 2026-05-04 22:52:40
7+
* Last Modified: 2026-05-06 19:56:15
88
* Modified By: 3urobeat
99
*
1010
* Copyright (c) 2025 - 2026 3urobeat <https://github.com/3urobeat>
@@ -80,14 +80,13 @@ export async function upsertLabels(labels: Label[]): Promise<void> {
8080

8181
}
8282

83-
8483
/**
8584
* Removes label
8685
* @throws Throws Exception on failure
8786
* @param labelID Label ID to remove
8887
* @returns
8988
*/
90-
async function removeLabel(labelID: string): Promise<void> {
89+
async function deleteLabel(labelID: string): Promise<void> {
9190

9291
await labelsDb.removeAsync({ id: labelID }, {});
9392

@@ -105,10 +104,10 @@ async function removeLabel(labelID: string): Promise<void> {
105104
* @param labelIDs Labels to remove
106105
* @returns
107106
*/
108-
export async function removeLabels(labelIDs: string[]): Promise<void> {
107+
export async function deleteLabels(labelIDs: string[]): Promise<void> {
109108

110-
// Call removeLabel for every label and await all resulting promises
111-
await Promise.all(labelIDs.map((e) => removeLabel(e)));
109+
// Call deleteLabel for every label and await all resulting promises
110+
await Promise.all(labelIDs.map((e) => deleteLabel(e)));
112111

113112
}
114113

@@ -172,7 +171,7 @@ export async function upsertLabelCategories(categories: Category[]): Promise<voi
172171
* @param categoryID Category ID to remove
173172
* @returns
174173
*/
175-
async function removeLabelCategory(categoryID: string): Promise<void> {
174+
async function deleteLabelCategory(categoryID: string): Promise<void> {
176175

177176
await labelCategoriesDb.removeAsync({ id: categoryID }, {});
178177

@@ -192,10 +191,10 @@ async function removeLabelCategory(categoryID: string): Promise<void> {
192191
* @param categoryIDs Labels to remove
193192
* @returns
194193
*/
195-
export async function removeLabelCategories(categoryIDs: string[]): Promise<void> {
194+
export async function deleteLabelCategories(categoryIDs: string[]): Promise<void> {
196195

197-
// Call removeLabelCategory for every category and await all resulting promises
198-
await Promise.all(categoryIDs.map((e) => removeLabelCategory(e)));
196+
// Call deleteLabelCategory for every category and await all resulting promises
197+
await Promise.all(categoryIDs.map((e) => deleteLabelCategory(e)));
199198

200199
}
201200

0 commit comments

Comments
 (0)