diff options
author | Yusuke Nemoto <kaakaa@users.noreply.github.com> | 2017-12-14 04:04:55 +0900 |
---|---|---|
committer | Chris <ccbrown112@gmail.com> | 2017-12-13 13:04:55 -0600 |
commit | ddd99f747663ff6f2a5446ab7fc92490ea90ddef (patch) | |
tree | a30dff3ef2ecde4fd516b743e2ac1312c9a3b277 /api4/params.go | |
parent | c39788b64b2d2c1f61968da234cac47c21e1affb (diff) | |
download | chat-ddd99f747663ff6f2a5446ab7fc92490ea90ddef.tar.gz chat-ddd99f747663ff6f2a5446ab7fc92490ea90ddef.tar.bz2 chat-ddd99f747663ff6f2a5446ab7fc92490ea90ddef.zip |
PLT-6896 per-paging for logs (#7903)
* PLT-6896 Read logs from last
* Getting rid of file.Stats
* remove deprecated value
* Make non-reassigned value constant
Diffstat (limited to 'api4/params.go')
-rw-r--r-- | api4/params.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/api4/params.go b/api4/params.go index 1f0fe8e63..64ee43771 100644 --- a/api4/params.go +++ b/api4/params.go @@ -11,9 +11,11 @@ import ( ) const ( - PAGE_DEFAULT = 0 - PER_PAGE_DEFAULT = 60 - PER_PAGE_MAXIMUM = 200 + PAGE_DEFAULT = 0 + PER_PAGE_DEFAULT = 60 + PER_PAGE_MAXIMUM = 200 + LOGS_PER_PAGE_DEFAULT = 10000 + LOGS_PER_PAGE_MAXIMUM = 10000 ) type ApiParams struct { @@ -43,6 +45,7 @@ type ApiParams struct { ActionId string Page int PerPage int + LogsPerPage int Permanent bool } @@ -165,5 +168,13 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { params.PerPage = val } + if val, err := strconv.Atoi(r.URL.Query().Get("logs_per_page")); err != nil || val < 0 { + params.LogsPerPage = LOGS_PER_PAGE_DEFAULT + } else if val > LOGS_PER_PAGE_MAXIMUM { + params.LogsPerPage = LOGS_PER_PAGE_MAXIMUM + } else { + params.LogsPerPage = val + } + return params } |