Skip to content

Commit

Permalink
Merge pull request #155 from arXiv/fastly-purge
Browse files Browse the repository at this point in the history
Fix logging for non version url
  • Loading branch information
mnazzaro authored Feb 21, 2024
2 parents c8a9c5f + 35860a2 commit 1fe927e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions ConversionContainer/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ google-cloud-logging = "^3.5.0"
bs4 = "^0.0.1"
filelock = "^3.12.2"
mysqlclient = "*"
requests = "^2.31.0"

[tool.poetry.dev-dependencies]
pytest-mock = "*"
Expand Down
28 changes: 9 additions & 19 deletions ConversionContainer/source/publish/fastly_purge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import requests

from flask import current_app

Expand All @@ -8,24 +9,13 @@ def fastly_purge_abs (paper_id: str, version: int, fastly_key: str):
"Accept": "application/json",
}
domains = ["arxiv.org", "web3.arxiv.org", "www.arxiv.org"]

for domain in domains:
url = f"https://{ domain }/abs/{ paper_id }"
_purge_url (f"https://{ domain }/abs/{ paper_id }", headers)
_purge_url (f"https://{ domain }/abs/{ paper_id }v{ version }", headers)

response = requests.request("PURGE", url, headers=headers)

if response.status_code == 200:
success.append(url)
else:
status_code = 500
msg = 'Error purging'
failed.append(url)

url = f"https://{ domain }/abs/{ paper_id }v{ version }"

response = requests.request("PURGE", url, headers=headers)

if response.status_code == 200:
logging.info(f'successfully purged { url }')
else:
logging.warning(f'failed to purge { url }')
def _purge_url (url: str, headers: dict):
response = requests.request("PURGE", url, headers=headers)
if response.status_code == 200:
logging.info(f'successfully purged { url }')
else:
logging.warning(f'failed to purge { url }')

0 comments on commit 1fe927e

Please sign in to comment.