MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / normalizeComments

Function normalizeComments

apps/server/internal/vault/vault.go:1227–1248  ·  view source on GitHub ↗
(inputs []NoteComment, notePath string)

Source from the content-addressed store, hash-verified

1225}
1226
1227func normalizeComments(inputs []NoteComment, notePath string) []NoteComment {
1228 out := make([]NoteComment, 0, len(inputs))
1229 seen := map[string]struct{}{}
1230 for _, input := range inputs {
1231 comment, ok := normalizeComment(input, notePath)
1232 if !ok {
1233 continue
1234 }
1235 if _, exists := seen[comment.ID]; exists {
1236 continue
1237 }
1238 seen[comment.ID] = struct{}{}
1239 out = append(out, comment)
1240 }
1241 sort.SliceStable(out, func(i, j int) bool {
1242 if out[i].CreatedAt == out[j].CreatedAt {
1243 return out[i].ID < out[j].ID
1244 }
1245 return out[i].CreatedAt < out[j].CreatedAt
1246 })
1247 return out
1248}
1249
1250func (v *Vault) readNoteCommentsLocked(rel string) ([]NoteComment, error) {
1251 notePath := filepath.ToSlash(rel)

Callers 2

Calls 2

normalizeCommentFunction · 0.85
appendFunction · 0.85

Tested by

no test coverage detected