Limit page size to 100, for fetching Person records from NB API

apparently that is the effective limit..so must honor it
This commit is contained in:
Lance Edgar 2023-10-16 11:12:51 -05:00
parent a7071d140b
commit 6cd71ea4c2
2 changed files with 6 additions and 1 deletions

View file

@ -103,7 +103,8 @@ class NationBuilderCachePersonImporter(FromNationBuilder, nationbuilder_importin
] + primary_address_fields
def get_host_objects(self):
return self.nationbuilder.get_people(page_size=500)
return self.nationbuilder.get_people(page_size=100,
progress=self.progress)
def normalize_host_object(self, person):

View file

@ -95,6 +95,10 @@ class NationBuilderWebAPI(object):
https://apiexplorer.nationbuilder.com/nationbuilder#People
"""
# nb. found this limit in practice, but it is not documented?!
if page_size > 100:
raise ValueError("page_size cannot be more than 100")
response = self.get('/api/v1/people/count')
count = response.json()['people_count']
pages = count // page_size