Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: tag count

Stevendf52bf5e63b4
diff --git a/server/router/api/v1/user_service_stats.go b/server/router/api/v1/user_service_stats.go
index 0f61eb6c3..1dc2b6e5b 100644
--- a/server/router/api/v1/user_service_stats.go
+++ b/server/router/api/v1/user_service_stats.go
@@ -125,23 +125,29 @@ func (s *APIV1Service) GetUserStats(ctx context.Context, request *v1pb.GetUserSt
displayTs = memo.UpdatedTs
}
displayTimestamps = append(displayTimestamps, timestamppb.New(time.Unix(displayTs, 0)))
-
- // Count different memo types based on content
- if memo.Payload != nil && memo.Payload.Property != nil {
- if memo.Payload.Property.HasLink {
- linkCount++
- }
- if memo.Payload.Property.HasCode {
- codeCount++
+ // Count different memo types based on content.
+ if memo.Payload != nil {
+ for _, tag := range memo.Payload.Tags {
+ if tagCount[tag] == 0 {
+ tagCount[tag] = 1
+ }
+ tagCount[tag]++
}
- if memo.Payload.Property.HasTaskList {
- todoCount++
- }
- if memo.Payload.Property.HasIncompleteTasks {
- undoCount++
+ if memo.Payload.Property != nil {
+ if memo.Payload.Property.HasLink {
+ linkCount++
+ }
+ if memo.Payload.Property.HasCode {
+ codeCount++
+ }
+ if memo.Payload.Property.HasTaskList {
+ todoCount++
+ }
+ if memo.Payload.Property.HasIncompleteTasks {
+ undoCount++
+ }
}
}
-
if memo.Pinned {
pinnedMemos = append(pinnedMemos, fmt.Sprintf("users/%d/memos/%d", userID, memo.ID))
}