search-with-images38
All checks were successful
Deploy on push / deploy (push) Successful in 1m8s

This commit is contained in:
Untone 2024-06-02 19:19:30 +03:00
parent 25964b6797
commit 6b8b61fa37

View File

@ -306,16 +306,19 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
shout_id = str(shout_id) shout_id = str(shout_id)
scores[shout_id] = sr.get("score") scores[shout_id] = sr.get("score")
hits_ids.append(shout_id) hits_ids.append(shout_id)
result = local_session().execute(query_shouts().filter(Shout.id.in_(hits_ids))).all()
if result: shouts_query = query_shouts().filter(Shout.id.in_(hits_ids))
logger.debug(result) shouts = []
logger.debug(len(result)) with local_session() as session:
shouts = [] result = session.execute(shouts_query).all()
for shout in result: if result:
logger.debug(shout) logger.debug(result)
shout.score = scores[f"{shout.id}"] logger.debug(len(result))
shouts.append(shout) for shout in result:
shouts.sort(key=lambda x: x.score, reverse=True) logger.debug(shout)
shout.score = scores[f"{shout.id}"]
shouts.append(shout)
shouts.sort(key=lambda x: x.score, reverse=True)
return shouts return shouts
return [] return []