Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): optimize json-cid view queries #1656

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading