Skip to content

Commit

Permalink
Merge pull request DDMAL#1656 from dchiller/i1655-optimize-json-cid
Browse files Browse the repository at this point in the history
fix(api): optimize json-cid view queries
  • Loading branch information
dchiller authored Oct 11, 2024
2 parents 1dfe503 + 7a3eeea commit f01050a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion django/cantusdb_project/main_app/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,13 @@ def json_cid_export(request, cantus_id: str) -> JsonResponse:
"""

# the API in OldCantus appears to only return chants, and no sequences.
chants = Chant.objects.filter(cantus_id=cantus_id).filter(source__published=True)
chants = (
Chant.objects.select_related(
"source", "source__holding_institution", "feast", "genre", "service"
)
.filter(cantus_id=cantus_id)
.filter(source__published=True)
)
chant_dicts = [{"chant": build_json_cid_dictionary(c, request)} for c in chants]
response = {"chants": chant_dicts}
return JsonResponse(response)
Expand Down

0 comments on commit f01050a

Please sign in to comment.