MCPcopy
hub / github.com/gotify/server / buildWithPaging

Function buildWithPaging

api/message.go:101–120  ·  view source on GitHub ↗
(ctx *gin.Context, paging *pagingParams, messages []*model.Message)

Source from the content-addressed store, hash-verified

99}
100
101func buildWithPaging(ctx *gin.Context, paging *pagingParams, messages []*model.Message) *model.PagedMessages {
102 next := ""
103 since := uint(0)
104 useMessages := messages
105 if len(messages) > paging.Limit {
106 useMessages = messages[:len(messages)-1]
107 since = useMessages[len(useMessages)-1].ID
108 url := location.Get(ctx)
109 url.Path = ctx.Request.URL.Path
110 query := url.Query()
111 query.Add("limit", strconv.Itoa(paging.Limit))
112 query.Add("since", strconv.FormatUint(uint64(since), 10))
113 url.RawQuery = query.Encode()
114 next = url.String()
115 }
116 return &model.PagedMessages{
117 Paging: model.Paging{Size: len(useMessages), Limit: paging.Limit, Next: next, Since: since},
118 Messages: toExternalMessages(useMessages),
119 }
120}
121
122func withPaging(ctx *gin.Context, f func(pagingParams *pagingParams)) {
123 params := &pagingParams{Limit: 100}

Callers 2

GetMessagesMethod · 0.85

Calls 2

toExternalMessagesFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…