Skip to content

Commit

Permalink
remove realtime record query cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jczhong84 committed Sep 13, 2023
1 parent e5baaad commit 72a30ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 0 additions & 4 deletions querybook/server/logic/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ def update_query_cell_by_id(query_cell_id, session=None):
} # ES requires this format for updates
_update(index_name, query_cell_id, updated_body)

# Try to update the vector store as well
from logic.vector_store import record_query_cell_from_es

record_query_cell_from_es(formatted_object)
except Exception:
LOG.error("failed to upsert {}. Will pass.".format(query_cell_id))

Expand Down
13 changes: 7 additions & 6 deletions querybook/server/logic/vector_store.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import time
from flask_login import current_user

from app.db import with_session
from langchain.docstore.document import Document
Expand Down Expand Up @@ -45,21 +46,21 @@ def get_sample_query_cells_by_table_name(table_name: str, k: int = 50):
from lib.elasticsearch.search_utils import get_matching_objects
from logic.elasticsearch import ES_CONFIG

# get timestamp of now
now = int(time.time())
# get timestamp of yesterday
end_time = int(time.time()) - 24 * 60 * 60
# get timestamp of 6 months ago
half_year_ago = now - 6 * 30 * 24 * 60 * 60
start_time = end_time - 6 * 30 * 24 * 60 * 60

filters = [
["full_table_name", [f"{table_name}"]],
["query_type", "query_cell"],
["statement_type", ["SELECT"]],
["startDate", half_year_ago],
["endDate", now],
["startDate", start_time],
["endDate", end_time],
]

query = construct_query_search_query(
uid=1,
uid=current_user.id if current_user else 1,
keywords="",
filters=filters,
limit=min(
Expand Down

0 comments on commit 72a30ad

Please sign in to comment.