scored-subquery-fix-3
All checks were successful
Deploy to core / deploy (push) Successful in 1m38s

This commit is contained in:
Untone 2024-01-29 01:57:34 +03:00
parent 1066b85e1b
commit 35f7a35f27

View File

@ -363,16 +363,17 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
# Use the subquery in the main query
q = (
select([subquery])
select([subquery.c.Shout, subquery.c.score])
.order_by(desc(subquery.c.score))
.limit(limit)
.offset(offset)
)
shouts_data = []
for shout, score in session.execute(q).all():
sdict = shout.dict()
sdict['score'] = score
shouts_data.append(sdict)
results = session.execute(q).all()
logger.debug(f'search found {len(results)} results')
# Directly build the shouts_data list within the loop
shouts_data = [shout.Shout.dict() for score, shout in results]
return shouts_data