Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanCarloMachado committed Jun 25, 2024
1 parent 7e6e03c commit 21c9a7e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
18 changes: 16 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ chromadb = ">=0.5.0"
tiny-data-warehouse = ">=0.1.5"


datadog = "^0.49.1"
[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
pre-commit = "^2.20.0"
Expand Down
9 changes: 9 additions & 0 deletions python_search/search/search_ui/search_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

from datadog import initialize, statsd

options = {
'statsd_host':'127.0.0.1',
'statsd_port':8125
}

initialize(**options)
9 changes: 6 additions & 3 deletions python_search/search/search_ui/terminal_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from python_search.search.search_ui.bm25_search import Bm25Search
from python_search.search.search_ui.search_actions import Actions
from python_search.search.search_ui.semantic_search import SemanticSearch
from python_search.search.search_ui.search_utils import statsd

from python_search.theme import get_current_theme
from python_search.host_system.system_paths import SystemPaths
Expand Down Expand Up @@ -40,6 +41,7 @@ def run(self):
Rrun the application main loop
"""

statsd.increment("python_search_run_triggered")
self._hide_cursor()
self.query = ""
self.selected_row = 0
Expand Down Expand Up @@ -68,6 +70,7 @@ def run(self):
self.matches.append(key)

c = self.get_caracter()
statsd.increment("python_search_run_get_char")
self.process_chars(self.query, c)

def search(self, query):
Expand Down Expand Up @@ -165,11 +168,11 @@ def process_chars(self, query: str, c: str):
self.selected_row = self.selected_row - 1
elif c == ".":
self.selected_query += 1
self.query = self.get_query(self.selected_query)
self.query = self.get_previously_used_query(self.selected_query)
elif c == ",":
if self.selected_query >= 0:
self.selected_query -= 1
self.query = self.get_query(self.selected_query)
self.query = self.get_previously_used_query(self.selected_query)
elif c == "+":
sys.exit(0)
elif ord_c == 68 or c == ";":
Expand All @@ -195,7 +198,7 @@ def process_chars(self, query: str, c: str):
self.query += c
self.selected_row = 0

def get_query(self, position):
def get_previously_used_query(self, position) -> str:
# len
df = self._get_data_warehouse().event("python_search_typed_query")
if position >= len(df):
Expand Down

0 comments on commit 21c9a7e

Please sign in to comment.