feat: improved search results in command palette

This commit is contained in:
Jannat Patel
2025-11-25 19:44:31 +05:30
parent c7915e2c3d
commit eab43a66cf
11 changed files with 474 additions and 8 deletions

29
lms/command_palette.py Normal file
View File

@@ -0,0 +1,29 @@
import frappe
@frappe.whitelist()
def search_sqlite(query: str):
from lms.sqlite import LearningSearch, LearningSearchIndexMissingError
search = LearningSearch()
try:
result = search.search(query)
except LearningSearchIndexMissingError:
return []
groups = {}
print(result)
for r in result["results"]:
doctype = r["doctype"]
if doctype == "LMS Course":
groups.setdefault("Courses", []).append(r)
elif doctype == "LMS Batch":
groups.setdefault("Batches", []).append(r)
out = []
for key in groups:
out.append({"title": key, "items": groups[key]})
return out