From 7e7f3f376887e7b4ab1a5a49606e54743f4d8198 Mon Sep 17 00:00:00 2001 From: Alberto Papaleo Date: Wed, 19 Apr 2023 10:13:44 -0400 Subject: [PATCH] update users_filter_by to use pagination --- actions/users_filter_by.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/actions/users_filter_by.py b/actions/users_filter_by.py index 095d049..b5d8bf7 100644 --- a/actions/users_filter_by.py +++ b/actions/users_filter_by.py @@ -24,16 +24,21 @@ def run(self, **kwargs): attrs = kwargs.pop('attributes') res = super(FilterBy, self).run(**kwargs) - for user in res['members']: - match = True - for key, val in attrs.items(): - if isinstance(val, six.string_types): - if not fnmatch(user.get(key, ''), val): + while res.get('response_metadata').get('next_cursor'): + for user in res['members']: + match = True + for key, val in attrs.items(): + if isinstance(val, six.string_types): + if not fnmatch(user.get(key, ''), val): + match = False + elif user.get(key) != val: match = False - elif user.get(key) != val: - match = False - if match: - users.append(user) + if match: + users.append(user) + + kwargs.update({'cursor': res.get('response_metadata').get('next_cursor')}) + self.logger.debug(f"Next cursor: {kwargs.get('cursor')}") + res = super(FilterBy, self).run(**kwargs) return users