[enh] allow to limit to number of journals per categories

This commit is contained in:
Laurent Peuch 2016-06-24 08:46:12 +02:00
parent 278f692a2f
commit 5dcf0b782f
2 changed files with 9 additions and 1 deletions

View file

@ -1600,3 +1600,8 @@ journals:
list:
action_help: List journals
api: GET /journals
arguments:
-l:
full: --limit
help: Maximum number of journals per categories
type: int

View file

@ -36,7 +36,7 @@ JOURNALS_PATH = '/var/log/journals/'
logger = getActionLogger('yunohost.journals')
def journals_list():
def journals_list(limit=None):
"""
List domains
@ -66,6 +66,9 @@ def journals_list():
result[category] = list(reversed(sorted(result[category], key=lambda x: x["started_at"])))
if limit is not None:
result[category] = result[category][:limit]
return result