chore: resolve conflicts

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang
2024-10-01 17:29:39 +05:30
parent 7ff97794f4
commit 13f5634570
3 changed files with 2 additions and 42 deletions

View File

@@ -37,18 +37,9 @@ def is_redisearch_enabled():
def is_search_module_loaded():
try:
cache = frappe.cache()
<<<<<<< HEAD
out = cache.execute_command("MODULE LIST")
parsed_output = " ".join(
" ".join([frappe.as_unicode(s) for s in o if not isinstance(s, int)]) for o in out
)
return "search" in parsed_output
=======
for module in cache.module_list():
if module.get(b"name") == b"search":
return True
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
except Exception:
return False # handling older redis versions
@@ -66,11 +57,7 @@ def if_redisearch_enabled(function):
def make_key(key):
<<<<<<< HEAD
return f"{frappe.conf.db_name}|{key}".encode()
=======
return frappe.cache().make_key(key)
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
@if_redisearch_enabled
@@ -100,14 +87,8 @@ def create_website_items_index():
idx_fields = [to_search_field(f) for f in idx_fields]
<<<<<<< HEAD
client.create_index(
[TextField("web_item_name", sortable=True), *idx_fields],
=======
# TODO: sortable?
index.create_index(
[TextField("web_item_name", sortable=True)] + idx_fields,
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
[TextField("web_item_name", sortable=True), *idx_fields],
definition=idx_def,
)
@@ -202,16 +183,8 @@ def define_autocomplete_dictionary():
@if_redisearch_enabled
def create_items_autocomplete_dict():
"Add items as suggestions in Autocompleter."
<<<<<<< HEAD
items = frappe.get_all("Website Item", fields=["web_item_name", "item_group"], filters={"published": 1})
=======
ac = frappe.cache().ft()
items = frappe.get_all(
"Website Item", fields=["web_item_name", "item_group"], filters={"published": 1}
)
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
items = frappe.get_all("Website Item", fields=["web_item_name", "item_group"], filters={"published": 1})
for item in items:
ac.sugadd(WEBSITE_ITEM_NAME_AUTOCOMPLETE, Suggestion(item.web_item_name))

View File

@@ -89,21 +89,12 @@ def product_search(query, limit=10, fuzzy_search=True):
# TODO: Check perf/correctness with Suggestions & Query vs only Query
# TODO: Use Levenshtein Distance in Query (max=3)
<<<<<<< HEAD
ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=red)
client = Client(make_key(WEBSITE_ITEM_INDEX), conn=red)
suggestions = ac.get_suggestions(
query,
num=limit,
fuzzy=fuzzy_search and len(query) > 3, # Fuzzy on length < 3 can be real slow
=======
redisearch = redis.ft(WEBSITE_ITEM_INDEX)
suggestions = redisearch.sugget(
WEBSITE_ITEM_NAME_AUTOCOMPLETE,
query,
num=limit,
fuzzy=fuzzy_search and len(query) > 3,
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
)
# Build a query

View File

@@ -12,12 +12,8 @@ dependencies = [
"pycountry~=20.7.3",
"python-stdnum~=1.16",
"Unidecode~=1.2.0",
<<<<<<< HEAD
"redisearch~=2.1.0",
"rapidfuzz~=2.15.0",
"holidays~=0.28",
=======
>>>>>>> 4a38ce659d (refactor!: drop redisearch)
# integration dependencies
"gocardless-pro~=1.22.0",