This commit is contained in:
parent
1066b85e1b
commit
35f7a35f27
|
@ -363,16 +363,17 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
|
||||||
|
|
||||||
# Use the subquery in the main query
|
# Use the subquery in the main query
|
||||||
q = (
|
q = (
|
||||||
select([subquery])
|
select([subquery.c.Shout, subquery.c.score])
|
||||||
.order_by(desc(subquery.c.score))
|
.order_by(desc(subquery.c.score))
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
)
|
)
|
||||||
shouts_data = []
|
|
||||||
for shout, score in session.execute(q).all():
|
results = session.execute(q).all()
|
||||||
sdict = shout.dict()
|
logger.debug(f'search found {len(results)} results')
|
||||||
sdict['score'] = score
|
|
||||||
shouts_data.append(sdict)
|
# Directly build the shouts_data list within the loop
|
||||||
|
shouts_data = [shout.Shout.dict() for score, shout in results]
|
||||||
|
|
||||||
return shouts_data
|
return shouts_data
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user