Skip to content

Commit

Permalink
Don't retry 410, allow search results to be passed to APIEventScraper…
Browse files Browse the repository at this point in the history
….events
  • Loading branch information
hancush committed Jan 30, 2025
1 parent 851bb7a commit 8781cbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions legistar/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ def pages(self, url, params=None, item_key=None):
page_num += 1

def accept_response(self, response, **kwargs):
'''
"""
This overrides a method that controls whether
the scraper should retry on an error. We don't
want to retry if the API returns a 400
'''
return response.status_code < 401
want to retry if the API returns a 400, except for
410, which means the record no longer exists.
"""
return response.status_code < 401 or response.status_code == 410
5 changes: 3 additions & 2 deletions legistar/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ def api_events(self, since_datetime=None):
params=params,
item_key="EventId")

def events(self, since_datetime=None):
for api_event in self.api_events(since_datetime=since_datetime):
def events(self, since_datetime=None, api_events=None):

for api_event in api_events or self.api_events(since_datetime=since_datetime):

time_str = api_event['EventTime']
if not time_str: # If we don't have an event time, skip it
Expand Down

0 comments on commit 8781cbf

Please sign in to comment.