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

This commit is contained in:
2024-06-02 15:56:17 +03:00
parent 67e4cacb28
commit 465d9093bd
2 changed files with 9 additions and 9 deletions

View File

@@ -297,14 +297,19 @@ async def load_shouts_feed(_, info, options):
async def load_shouts_search(_, _info, text, limit=50, offset=0):
if isinstance(text, str) and len(text) > 2:
results = await search_text(text, limit, offset)
shouts_ids = []
scores = {}
hits_ids = []
for sr in results:
shout_id = sr.get("id")
if shout_id:
shouts_ids.append(int(shout_id))
shout_id = int(shout_id)
scores[shout_id] = sr.get("score")
hits_ids.append(shout_id)
shouts = []
with local_session() as session:
shouts = session.query(Shout).filter(Shout.id.in_(shouts_ids)).all()
shouts = session.query(Shout).filter(Shout.id.in_(hits_ids)).all()
for shout in shouts:
shout["score"] = scores[int(shout.id)]
return shouts
return []