Skip to content

Commit

Permalink
Fixed: Unnecessary select_related items
Browse files Browse the repository at this point in the history
  • Loading branch information
ahankinson committed Jul 16, 2024
1 parent f0c6fa2 commit 694e376
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions django/cantusdb_project/main_app/views/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,19 @@ def get_context_data(self, **kwargs):

context = super().get_context_data(**kwargs)

if source.segment and source.segment.id == 4064:
if source.segment and source.segment_id == 4064:
# if this is a sequence source
context["sequences"] = source.sequence_set.select_related("source").order_by("s_sequence")
sequences = source.sequence_set.select_related("genre", "office")
context["sequences"] = sequences.order_by("s_sequence")
context["folios"] = (
source.sequence_set.select_related("source").values_list("folio", flat=True)
sequences.values_list("folio", flat=True)
.distinct()
.order_by("folio")
)
else:
# if this is a chant source
folios = (
source.chant_set.select_related("source").values_list("folio", flat=True)
source.chant_set.values_list("folio", flat=True)
.distinct()
.order_by("folio")
)
Expand Down

0 comments on commit 694e376

Please sign in to comment.