From 92120ca47e1b4ab28a518eaa00ce16d72ab77667 Mon Sep 17 00:00:00 2001 From: Petar Efnushev Date: Mon, 6 Jun 2016 10:23:57 +0200 Subject: [PATCH] Change db logger pagination limit param name --- ckanext/harvest/logic/action/get.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ckanext/harvest/logic/action/get.py b/ckanext/harvest/logic/action/get.py index dc827fc..2415278 100644 --- a/ckanext/harvest/logic/action/get.py +++ b/ckanext/harvest/logic/action/get.py @@ -316,7 +316,7 @@ def harvesters_info_show(context,data_dict): def harvest_log_list(context,data_dict): '''Returns a list of harvester log entries. - :param per_page: number of logs to be shown default: 100 + :param limit: number of logs to be shown default: 100 :param offset: use with ``per_page`` default: 0 :param level: filter log entries by level(debug, info, warning, error, critical) ''' @@ -327,9 +327,16 @@ def harvest_log_list(context,data_dict): session = context['session'] try: - per_page = int(data_dict.get('per_page', 100)) + limit = int(data_dict.get('limit', 100)) except ValueError: - per_page = 100 + limit = 100 + + if data_dict.get('per_page', False): + try: + limit = int(data_dict.get('per_page', 100)) + except ValueError: + limit = 100 + try: offset = int(data_dict.get('offset', 0)) except ValueError: @@ -343,7 +350,7 @@ def harvest_log_list(context,data_dict): query = query.filter(HarvestLog.level==level.upper()) query = query.order_by(HarvestLog.created.desc()) - logs = query.offset(offset).limit(per_page).all() + logs = query.offset(offset).limit(limit).all() out = [harvest_log_dictize(obj, context) for obj in logs] return out