Skip to content

Commit

Permalink
Update station-maintenance-aggregated.py
Browse files Browse the repository at this point in the history
fix pagination
  • Loading branch information
cristianosticca-pagopa authored Jan 16, 2025
1 parent a2a7293 commit 6cfee87
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main/scripts/station-maintenance-aggregated.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,25 @@ def get_pa_for_broker(broker_code):
headers = {
'Ocp-Apim-Subscription-Key': subscription_key_backoffice_ext_pa
}
params = {'page': page, 'limit': limit}
response = requests.get(base_url, headers=headers, params=params)
response.raise_for_status()
return response.json()

all_creditor_institutions = []

while True:
params = {'page': page, 'limit': limit}
response = requests.get(base_url, headers=headers, params=params)
response.raise_for_status()

data = response.json()
creditor_institutions = data.get('creditorInstitutions', [])
all_creditor_institutions.extend(creditor_institutions)

total_pages = data.get('pageInfo', {}).get('totalPages', 1)
if page >= total_pages - 1:
break
page += 1

return all_creditor_institutions


def create_betterstack_maintenance(data):

Expand Down

0 comments on commit 6cfee87

Please sign in to comment.