config.gno
0.80 Kb · 45 lines
1package acr
2
3import (
4 "chain"
5 "strconv"
6
7 "gno.land/p/akkadia/v0/accesscontrol"
8 "gno.land/r/akkadia/v0/admin"
9)
10
11const (
12 SetListLimitEvent = "SetListLimit"
13)
14
15var (
16 listLimit int = 100 // Max items per list query
17)
18
19// SetListLimit sets the max items per list query (admin only)
20func SetListLimit(cur realm, limit int) {
21 assertNotFrozen()
22 caller := accesscontrol.MustGetAdminCaller(0, cur, admin.IsAdmin)
23 if limit < 1 {
24 panic("limit must be at least 1")
25 }
26
27 oldLimit := listLimit
28 listLimit = limit
29
30 chain.Emit(
31 SetListLimitEvent,
32 "admin", caller.String(),
33 "oldLimit", strconv.Itoa(oldLimit),
34 "newLimit", strconv.Itoa(limit),
35 )
36}
37
38// GetListLimit returns the max items per list query
39func GetListLimit() int {
40 return listLimit
41}
42
43func pageOffset(page int, count int) int {
44 return (page - 1) * count
45}