Add max_pages arg for API get_people_with_tag() method
				
					
				
			for sake of testing, limit how many results to fetch
This commit is contained in:
		
							parent
							
								
									dfbd8f1652
								
							
						
					
					
						commit
						5438db9f27
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -110,7 +110,7 @@ class NationBuilderWebAPI(object): | |||
|                                message="Fetching Person data from NationBuilder") | ||||
|         return people | ||||
| 
 | ||||
|     def get_people_with_tag(self, tag, page_size=100, **kwargs): | ||||
|     def get_people_with_tag(self, tag, page_size=100, max_pages=None, **kwargs): | ||||
|         """ | ||||
|         Retrieve all Person records with the given tag. | ||||
| 
 | ||||
|  | @ -124,11 +124,15 @@ class NationBuilderWebAPI(object): | |||
|         response = self.get(api_method) | ||||
|         data = response.json() | ||||
|         people.extend(data['results']) | ||||
|         pages = 1 | ||||
| 
 | ||||
|         # get more pages, until complete | ||||
|         while data['next']: | ||||
|             if max_pages and pages >= max_pages: | ||||
|                 break | ||||
|             response = self.get(data['next']) | ||||
|             data = response.json() | ||||
|             people.extend(data['results']) | ||||
|             pages += 1 | ||||
| 
 | ||||
|         return people | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar