From ab302a231ce7f4c43cd1872f7e80047b9ea57461 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 17 2018 08:12:45 +0000 Subject: Add support for pagination to the search_groups method Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 3781858..988daf0 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3785,7 +3785,7 @@ def get_group_types(session, group_type=None): def search_groups(session, pattern=None, group_name=None, group_type=None, - display_name=None): + display_name=None, offset=None, limit=None, count=False): ''' Return the groups based on the criteria specified. ''' @@ -3819,8 +3819,15 @@ def search_groups(session, pattern=None, group_name=None, group_type=None, model.PagureGroup.group_type == group_type ) + if offset: + query = query.offset(offset) + if limit: + query = query.limit(limit) + if group_name: return query.first() + elif count: + return query.count() else: return query.all()