Skip to content

Commit bfc1719

Browse files
committed
chore: update script so that it grabs release note from S3 bucket
1 parent 825a370 commit bfc1719

1 file changed

Lines changed: 17 additions & 35 deletions

File tree

scripts/seed_release_notes_all.py

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,18 @@
11
"""Seed release-notes RenderedContent for every Version in the local DB.
22
3-
Fetches each version's history page from the boostorg/website repo on GitHub
4-
(the same source the prod pipeline falls back to when S3 is empty), runs it
5-
through `process_release_notes` for parity with prod content, and upserts a
6-
`RenderedContent` row keyed by `version.release_notes_cache_key`.
3+
Uses the same source-of-truth strategy as prod (`get_release_notes_for_version`):
4+
S3 first (asciidoc, for 1.90.0 onwards), falling back to the boostorg/website
5+
GitHub history page (html) for older versions. Upserts a `RenderedContent` row
6+
keyed by `version.release_notes_cache_key`.
77
88
Run from the project root:
99
10-
docker compose exec web ./manage.py shell < scripts/seed_release_notes_all.py
10+
docker compose run web ./manage.py shell < scripts/seed_release_notes_all.py
1111
"""
1212

13-
import requests
14-
1513
from core.models import RenderedContent
1614
from versions.models import Version
17-
from versions.releases import process_release_notes
18-
19-
BASE_URL = "https://raw.githubusercontent.com/boostorg/website/master/users/history/"
20-
TIMEOUT = 30
21-
22-
23-
def _filename_for(version):
24-
# boost-1.89.0 -> version_1_89_0, mirrors get_release_notes_for_version_github.
25-
return version.non_beta_slug.replace("boost", "version").replace("-", "_")
26-
27-
28-
def _fetch(filename):
29-
url = f"{BASE_URL}{filename}.html"
30-
response = requests.get(url, timeout=TIMEOUT)
31-
if response.status_code == 404:
32-
# Some beta release notes end in _x.html instead of _0.html.
33-
fallback = filename.rsplit("_", 1)[0] + "_x"
34-
response = requests.get(f"{BASE_URL}{fallback}.html", timeout=TIMEOUT)
35-
return response
36-
15+
from versions.releases import get_release_notes_for_version
3716

3817
seeded, skipped, failed = [], [], []
3918

@@ -42,21 +21,24 @@ def _fetch(filename):
4221
skipped.append((version.name, "no version number"))
4322
continue
4423

45-
filename = _filename_for(version)
4624
try:
47-
response = _fetch(filename)
48-
response.raise_for_status()
49-
except requests.RequestException as exc:
25+
content, processed_content, content_type = get_release_notes_for_version(
26+
version.pk
27+
)
28+
except Exception as exc:
5029
failed.append((version.name, str(exc)))
5130
continue
5231

53-
processed = process_release_notes(response.content)
32+
if not content:
33+
skipped.append((version.name, "no release notes found"))
34+
continue
35+
5436
RenderedContent.objects.update_or_create(
5537
cache_key=version.release_notes_cache_key,
5638
defaults={
57-
"content_type": "text/html",
58-
"content_original": response.text,
59-
"content_html": processed,
39+
"content_type": content_type,
40+
"content_original": content,
41+
"content_html": processed_content,
6042
},
6143
)
6244
seeded.append(version.name)

0 commit comments

Comments
 (0)