Skip to content

Commit

Permalink
chore: regenerate index if frappe.clear_cache-ed
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Jan 29, 2024
1 parent a388e9a commit b6eddbd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gameplan/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

UNSAFE_CHARS = re.compile(r"[\[\]{}<>+]")

INDEX_BUILD_FLAG = "discussions_index_in_progress"


class GameplanSearch(Search):
def __init__(self) -> None:
Expand Down Expand Up @@ -183,10 +185,10 @@ def get_accessible_projects(self):


def build_index():
frappe.cache().set_value("discussions_index_in_progress", True)
frappe.cache().set_value(INDEX_BUILD_FLAG, True)
search = GameplanSearch()
search.build_index()
frappe.cache().set_value("discussions_index_in_progress", False)
frappe.cache().set_value(INDEX_BUILD_FLAG, False)


def build_index_in_background():
Expand All @@ -196,5 +198,5 @@ def build_index_in_background():

def build_index_if_not_exists():
search = GameplanSearch()
if not search.index_exists():
if not search.index_exists() or not frappe.cache.exists(INDEX_BUILD_FLAG):
build_index()

0 comments on commit b6eddbd

Please sign in to comment.