From 6cd71ea4c2574d0d87444646d4eff1c54edbb090 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 16 Oct 2023 11:12:51 -0500 Subject: [PATCH] Limit page size to 100, for fetching Person records from NB API apparently that is the effective limit..so must honor it --- rattail_nationbuilder/importing/nationbuilder.py | 3 ++- rattail_nationbuilder/nationbuilder/webapi.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rattail_nationbuilder/importing/nationbuilder.py b/rattail_nationbuilder/importing/nationbuilder.py index 00d3d59..22306b0 100644 --- a/rattail_nationbuilder/importing/nationbuilder.py +++ b/rattail_nationbuilder/importing/nationbuilder.py @@ -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): diff --git a/rattail_nationbuilder/nationbuilder/webapi.py b/rattail_nationbuilder/nationbuilder/webapi.py index 019db08..82a02da 100644 --- a/rattail_nationbuilder/nationbuilder/webapi.py +++ b/rattail_nationbuilder/nationbuilder/webapi.py @@ -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