Skip to content

Commit

Permalink
Merge pull request #292 from arXiv/ARXIVCE-2383-fix-function-for-high…
Browse files Browse the repository at this point in the history
…-number-of-keys

bugfix, dont call with too many items
  • Loading branch information
kyokukou committed Jul 5, 2024
2 parents a447544 + 7389c65 commit a96520e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions arxiv/integration/fastly/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def _purge_multiple_keys(keys: List[str], service_id:str, api_instance: PurgeApi
if len(keys)> MAX_PURGE_KEYS:
_purge_multiple_keys(keys[0:MAX_PURGE_KEYS], service_id, api_instance, soft_purge)
_purge_multiple_keys(keys[MAX_PURGE_KEYS:], service_id, api_instance,soft_purge)

options = {
'service_id': service_id,
'purge_response': {'surrogate_keys':keys,}
}
if soft_purge:
options['fastly_soft_purge']=1
api_response=api_instance.bulk_purge_tag(**options)
logger.debug(f"Bulk purge keys response: {api_response}")
else:
options = {
'service_id': service_id,
'purge_response': {'surrogate_keys':keys,}
}
if soft_purge:
options['fastly_soft_purge']=1
api_response=api_instance.bulk_purge_tag(**options)
logger.debug(f"Bulk purge keys response: {api_response}")
return
1 change: 1 addition & 0 deletions arxiv/integration/tests/test_fastly.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_purge_over_max_keys(self, MockApiClient, MockPurgeApi: PurgeApi):
]

mock_api_instance.bulk_purge_tag.assert_has_calls(calls, any_order=True)
self.assertEqual(mock_api_instance.bulk_purge_tag.call_count, len(calls))


#tests for adding surrogate keys helper function
Expand Down

0 comments on commit a96520e

Please sign in to comment.