diff --git a/querybook/server/logic/elasticsearch.py b/querybook/server/logic/elasticsearch.py index 20e852296..e452755e0 100644 --- a/querybook/server/logic/elasticsearch.py +++ b/querybook/server/logic/elasticsearch.py @@ -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)) diff --git a/querybook/server/logic/vector_store.py b/querybook/server/logic/vector_store.py index 9ffe63129..8677b1f50 100644 --- a/querybook/server/logic/vector_store.py +++ b/querybook/server/logic/vector_store.py @@ -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 @@ -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(