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 search vector update #1457

Merged
merged 1 commit into from
Dec 4, 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
15 changes: 12 additions & 3 deletions tilavarauspalvelu/models/reservation_unit/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,42 +156,51 @@ def update_search_vectors(self, reservation_unit_pk: int | None = None) -> None:
models.F(f"description_{lang}"),
#
# Additional search terms
models.Value(" ".join(term for term in reservation_unit.search_terms)),
models.Value(
" ".join(term for term in reservation_unit.search_terms),
output_field=models.CharField(),
),
#
# Joins are not allowed in search vectors, so we compute them as values beforehand.
models.Value(
getattr(reservation_unit.unit, f"name_{lang}", ""),
getattr(reservation_unit.unit, f"name_{lang}", "") or "",
output_field=models.CharField(),
),
models.Value(
getattr(reservation_unit.reservation_unit_type, f"name_{lang}", ""),
getattr(reservation_unit.reservation_unit_type, f"name_{lang}", "") or "",
output_field=models.CharField(),
),
models.Value(
" ".join(
name
for inst in reservation_unit.spaces.all()
if (name := getattr(inst, f"name_{lang}", ""))
),
output_field=models.CharField(),
),
models.Value(
" ".join(
name
for inst in reservation_unit.resources.all()
if (name := getattr(inst, f"name_{lang}", ""))
),
output_field=models.CharField(),
),
models.Value(
" ".join(
name
for inst in reservation_unit.purposes.all()
if (name := getattr(inst, f"name_{lang}", ""))
),
output_field=models.CharField(),
),
models.Value(
" ".join(
name
for inst in reservation_unit.equipments.all()
if (name := getattr(inst, f"name_{lang}", ""))
),
output_field=models.CharField(),
),
#
config=config,
Expand Down
Loading