aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2024-10-20 16:00:17 +0000
committerMohamed Bassem <me@mbassem.com>2024-10-20 16:00:17 +0000
commit4086c37b830c3c4141b37052e3c192a750470084 (patch)
tree7bab9bff1bdc7f7b4b48987b68a6b99b7b6fcfee /packages/trpc/routers
parente89a38680532c3ab72ef26dfe88bb64476b709ab (diff)
downloadkarakeep-4086c37b830c3c4141b37052e3c192a750470084.tar.zst
fix: Improve field names in the tag APIs
Diffstat (limited to 'packages/trpc/routers')
-rw-r--r--packages/trpc/routers/tags.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/trpc/routers/tags.ts b/packages/trpc/routers/tags.ts
index c04593c9..c080bad8 100644
--- a/packages/trpc/routers/tags.ts
+++ b/packages/trpc/routers/tags.ts
@@ -80,7 +80,9 @@ export const tagsAppRouter = router({
throw new TRPCError({ code: "NOT_FOUND" });
}
- const countAttachedBy = res.reduce<Record<ZAttachedByEnum, number>>(
+ const numBookmarksByAttachedType = res.reduce<
+ Record<ZAttachedByEnum, number>
+ >(
(acc, curr) => {
if (curr.attachedBy) {
acc[curr.attachedBy]++;
@@ -93,8 +95,11 @@ export const tagsAppRouter = router({
return {
id: res[0].id,
name: res[0].name,
- count: Object.values(countAttachedBy).reduce((s, a) => s + a, 0),
- countAttachedBy,
+ numBookmarks: Object.values(numBookmarksByAttachedType).reduce(
+ (s, a) => s + a,
+ 0,
+ ),
+ numBookmarksByAttachedType,
};
}),
delete: authedProcedure
@@ -343,8 +348,8 @@ export const tagsAppRouter = router({
const resp = tags.map(({ tagsOnBookmarks, ...rest }) => ({
...rest,
- count: tagsOnBookmarks.length,
- countAttachedBy: tagsOnBookmarks.reduce<
+ numBookmarks: tagsOnBookmarks.length,
+ numBookmarksByAttachedType: tagsOnBookmarks.reduce<
Record<ZAttachedByEnum, number>
>(
(acc, curr) => {