Skip to content

Commit

Permalink
Fix pinata pins cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Sep 4, 2024
1 parent b62b4e6 commit f7f2615
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .ci/pinata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ def headers():


def unpin_old(name, keep_latest):
resp = requests.get(f'{PINATA_API_URL}/data/pinList', headers=headers())
resp = requests.get(f'{PINATA_API_URL}/data/pinList', headers=headers(), params={
'pageLimit': 1000,
'status': 'pinned',
})
resp.raise_for_status()
resp = resp.json()

print("Total pins returned:", len(resp["rows"]))

entries_by_name = {}
for row in resp['rows']:
entry_name = row['metadata']['name']
Expand All @@ -42,6 +47,8 @@ def unpin_old(name, keep_latest):
entries = entries_by_name.setdefault(entry_name, [])
entries.append(row)

print(f"Found active pins:", len(entries_by_name))

for name, entries in entries_by_name.items():
entries.sort(key=lambda e: e['date_pinned'], reverse=True)

Expand Down

0 comments on commit f7f2615

Please sign in to comment.