Skip to content

Commit

Permalink
fix: tag stats
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jan 8, 2025
1 parent d9d6f73 commit 012ca1d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions web/src/store/v1/memoMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ export const useMemoTagList = () => {
const memos = Object.values(memoStore.getState().dataMapByName);
const tagAmounts: Record<string, number> = {};
memos.forEach((memo) => {
memo.tags.forEach((tag) => {
if (tagAmounts[tag]) {
tagAmounts[tag] += 1;
} else {
tagAmounts[tag] = 1;
const tagSet = new Set<string>();
for (const tag of memo.tags) {
const parts = tag.split("/");
let currentTag = "";
for (const part of parts) {
currentTag = currentTag ? `${currentTag}/${part}` : part;
tagSet.add(currentTag);
}
}
Array.from(tagSet).forEach((tag) => {
tagAmounts[tag] = tagAmounts[tag] ? tagAmounts[tag] + 1 : 1;
});
});
return tagAmounts;
Expand Down

0 comments on commit 012ca1d

Please sign in to comment.