Fix bug with supporting paginated search for recall memory

This commit is contained in:
Sarah Wooders 2024-01-03 18:32:13 -08:00
parent f71c855dce
commit 89b51a12cc
2 changed files with 9 additions and 18 deletions

View File

@ -280,23 +280,12 @@ class SQLStorageConnector(StorageConnector):
# todo: make fuzz https://stackoverflow.com/questions/42388956/create-a-full-text-search-index-with-sqlalchemy-on-postgresql/42390204#42390204
session = self.Session()
filters = self.get_filters({})
query = (
session.query(self.db_model).filter(*filters).filter(func.lower(self.db_model.text).contains(func.lower(query))).offset(offset)
)
if limit:
results = (
session.query(self.db_model)
.filter(*filters)
.filter(func.lower(self.db_model.text).contains(func.lower(query)))
.offset(offset)
.all()
)
else:
results = (
session.query(self.db_model)
.filter(*filters)
.filter(func.lower(self.db_model.text).contains(func.lower(query)))
.offset(offset)
.limit(limit)
.all()
)
query = query.limit(limit)
results = query.all()
# return [self.type(**vars(result)) for result in results]
return [result.to_record() for result in results]

View File

@ -310,10 +310,12 @@ class BaseRecallMemory(RecallMemory):
self.cache = {}
def text_search(self, query_string, count=None, start=None):
self.storage.query_text(query_string, count, start)
results = self.storage.query_text(query_string, count, start)
return results, len(results)
def date_search(self, start_date, end_date, count=None, start=None):
self.storage.query_date(start_date, end_date, count, start)
results = self.storage.query_date(start_date, end_date, count, start)
return results, len(results)
def __repr__(self) -> str:
total = self.storage.size()