search-simpler-query-fix-2
All checks were successful
Deploy to core / deploy (push) Successful in 1m42s
All checks were successful
Deploy to core / deploy (push) Successful in 1m42s
This commit is contained in:
parent
5e4ef40b21
commit
c061e5cdb3
|
@ -345,7 +345,7 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
|
||||||
|
|
||||||
shouts_data = []
|
shouts_data = []
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
results = list(session.execute(q).unique())
|
results = set(session.execute(q).all())
|
||||||
# print(results)
|
# print(results)
|
||||||
logger.debug(f'search found {len(results)} results')
|
logger.debug(f'search found {len(results)} results')
|
||||||
for x in results:
|
for x in results:
|
||||||
|
@ -382,7 +382,11 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
|
||||||
score = results_dict.get(shout_slug, {}).get('score', 0)
|
score = results_dict.get(shout_slug, {}).get('score', 0)
|
||||||
shout_data['score'] = score # Add the score to the dictionary
|
shout_data['score'] = score # Add the score to the dictionary
|
||||||
shouts_data.append(shout_data)
|
shouts_data.append(shout_data)
|
||||||
|
shouts_data = sorted(
|
||||||
|
shouts_data,
|
||||||
|
key=lambda x: float(x.get('score', '0')),
|
||||||
|
reverse=True,
|
||||||
|
)
|
||||||
return shouts_data
|
return shouts_data
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user