Skip to content

Commit

Permalink
don't query for rendered release_descriptions in JSON api (pypi#16273)
Browse files Browse the repository at this point in the history
JSON api only sends raw and content_type... so lets not query for rendered

Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
  • Loading branch information
ewdurbin and di authored Jul 16, 2024
1 parent 70d43c0 commit c5e7d0a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions warehouse/legacy/api/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from warehouse.cache.http import cache_control
from warehouse.cache.origin import origin_cache
from warehouse.packaging.models import File, Project, Release, ReleaseURL
from warehouse.packaging.models import Description, File, Project, Release, ReleaseURL
from warehouse.utils.cors import _CORS_HEADERS

_RELEASE_CACHE_DECORATOR = [
Expand Down Expand Up @@ -63,6 +63,14 @@ def _json_data(request, project, release, *, all_releases):
if not all_releases:
release_files = release_files.filter(Release.id == release.id)

# Get the raw description and description content type for this release
release_description = (
request.db.query(Description)
.options(Load(Description).load_only(Description.content_type, Description.raw))
.filter(Description.release == release)
.one()
)

# Finally set an ordering, and execute the query.
release_files = release_files.order_by(
Release._pypi_ordering.desc(), File.filename
Expand Down Expand Up @@ -134,8 +142,8 @@ def _json_data(request, project, release, *, all_releases):
"name": project.name,
"version": release.version,
"summary": release.summary,
"description_content_type": release.description.content_type,
"description": release.description.raw,
"description_content_type": release_description.content_type,
"description": release_description.raw,
"keywords": release.keywords,
"license": release.license,
"classifiers": list(release.classifiers),
Expand Down

0 comments on commit c5e7d0a

Please sign in to comment.