MCPcopy Index your code
hub / github.com/dnote/dnote / GetNotes

Method GetNotes

pkg/server/app/notes.go:266–291  ·  view source on GitHub ↗

GetNotes returns a list of matching notes

(userID int, params GetNotesParams)

Source from the content-addressed store, hash-verified

264
265// GetNotes returns a list of matching notes
266func (a *App) GetNotes(userID int, params GetNotesParams) (GetNotesResult, error) {
267 conn := getNotesBaseQuery(a.DB, userID, params)
268
269 var total int64
270 if err := conn.Model(database.Note{}).Count(&total).Error; err != nil {
271 return GetNotesResult{}, pkgErrors.Wrap(err, "counting total")
272 }
273
274 notes := []database.Note{}
275 if total != 0 {
276 conn = orderGetNotes(conn)
277 conn = database.PreloadNote(conn)
278 conn = paginate(conn, params.Page, params.PerPage)
279
280 if err := conn.Find(&notes).Error; err != nil {
281 return GetNotesResult{}, pkgErrors.Wrap(err, "finding notes")
282 }
283 }
284
285 res := GetNotesResult{
286 Notes: notes,
287 Total: total,
288 }
289
290 return res, nil
291}

Callers 5

getNotesMethod · 0.80
TestGetNotes_FTSSearchFunction · 0.80
TestGetNotes_AllFunction · 0.80

Calls 4

PreloadNoteFunction · 0.92
getNotesBaseQueryFunction · 0.85
orderGetNotesFunction · 0.85
paginateFunction · 0.85

Tested by 4

TestGetNotes_FTSSearchFunction · 0.64
TestGetNotes_AllFunction · 0.64