Skip to content

Commit 9e201f7

Browse files
committed
search
1 parent 2c3af7b commit 9e201f7

10 files changed

+12
-0
lines changed

pgml_todo/.gitignore renamed to .gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ GitHub.sublime-settings
136136
!.vscode/launch.json
137137
!.vscode/extensions.json
138138
.history
139+
*.pyc
140+
__pycache__
-149 Bytes
Binary file not shown.
-190 Bytes
Binary file not shown.

todo/__pycache__/apps.cpython-310.pyc

-424 Bytes
Binary file not shown.
-2.29 KB
Binary file not shown.
-1.25 KB
Binary file not shown.
Binary file not shown.
-160 Bytes
Binary file not shown.

todo/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ def search(self, request):
1919
Search the TODO list by embedding similarity.
2020
"""
2121
query = request.query_params.get("q")
22+
completed = request.query_params.get("completed")
23+
24+
if completed:
25+
completed = completed.lower() == "true"
26+
else:
27+
completed = False
28+
2229
if query:
2330
results = TodoItem.objects.annotate(
2431
# Use cosine similarty to find closest matches by their linguistic meaning
@@ -28,6 +35,9 @@ def search(self, request):
2835
)
2936
).order_by("similarity")
3037

38+
if completed:
39+
results = results.filter(completed=completed)
40+
3141
# If you want to see the query that is executed, uncomment the following line.
3242
# print(results.query)
3343

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy