Skip to content

Commit

Permalink
search only is_published
Browse files Browse the repository at this point in the history
  • Loading branch information
backface committed Oct 10, 2024
1 parent 83897bd commit 06a0260
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
12 changes: 8 additions & 4 deletions apps/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def search(request, target="all"):
| Q(first_name__icontains=q)
| Q(last_name__icontains=q)
).order_by("-username")

elif target == "semantic":
q_vector = create_embeddings(q)
objects = (
Expand All @@ -372,6 +373,7 @@ def search(request, target="all"):
)
# objects = objects.filter(cos_distance__lte=0.5).distinct()
objects = objects.distinct()

elif target == "projects":
objects = (
Project.objects.filter(is_published=True)
Expand All @@ -393,10 +395,12 @@ def search(request, target="all"):
.filter(search=q)
)
else:
objects = Project.objects.filter(
Q(name__icontains=q) | Q(notes__icontains=q)
).select_related("user")

objects = (
Project.objects.filter(is_published=True)
.filter(
Q(name__icontains=q) | Q(notes__icontains=q)
).select_related("user")
)
users = User.objects.filter(
Q(username__icontains=q)
| Q(first_name__icontains=q)
Expand Down
12 changes: 0 additions & 12 deletions pyrightconfig.json

This file was deleted.

0 comments on commit 06a0260

Please sign in to comment.