From b177adf3a7181277a05f63560aa6b03063b47fc6 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 28 Feb 2023 21:49:26 -0600 Subject: [PATCH] Return value of search_type in /config/type API endpoint - Remove need for interfaces to downcase content types returned by API before using the type in search and other API endpoint - Fix to check for search_type.name in plugin keys instead of value --- src/interface/emacs/khoj.el | 1 - src/khoj/interface/web/index.html | 2 +- src/khoj/routers/api.py | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index 1b8c8905..4aa1898a 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -281,7 +281,6 @@ Use `which-key` if available, else display simple message in echo area" (url-insert-file-contents config-url) (thread-last (json-parse-buffer :object-type 'alist) - (mapcar 'downcase) (mapcar 'intern))))) (defun khoj--construct-api-query (query content-type &optional rerank) diff --git a/src/khoj/interface/web/index.html b/src/khoj/interface/web/index.html index 3c1e03d7..42831f5d 100644 --- a/src/khoj/interface/web/index.html +++ b/src/khoj/interface/web/index.html @@ -65,7 +65,7 @@ function search(rerank=false) { // Extract required fields for search from form query = document.getElementById("query").value.trim(); - type = document.getElementById("type").value.toLowerCase(); + type = document.getElementById("type").value; results_count = document.getElementById("results-count").value || 6; console.log(`Query: ${query}, Type: ${type}`); diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index 6c433cd1..ad6d9919 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -30,10 +30,10 @@ def get_default_config_data(): def get_config_types(): """Get configured content types""" return [ - search_type.name + search_type.value for search_type in SearchType if any(search_type.value == configured_content_type[0] for configured_content_type in state.config.content_type) - or search_type.value in state.config.content_type.plugins.keys() + or search_type.name in state.config.content_type.plugins.keys() ]