search-fix-2

This commit is contained in:
Untone 2024-01-26 04:05:25 +03:00
parent 3f703ad357
commit 1b80d596cb
3 changed files with 31 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "discoursio-core"
version = "0.2.21"
version = "0.2.22"
description = "core module for discours.io"
authors = ["discoursio devteam"]
license = "MIT"
@ -18,7 +18,6 @@ ariadne = "^0.21"
aiohttp = "^3.9.1"
google-oauth2-tool = "^0.0.3"
google-api-python-client = "^2.114.0"
pandas = "^2.2.0"
pre-commit = "^3.6.0"
granian = "^1.0.1"

View File

@ -326,9 +326,36 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
print(f'[resolvers.reader] searched, preparing {len(results)} results')
for x in results:
shout = x[0]
shout_slug = shout.dict().get('slug', '')
shout_data = shout.dict()
shout_slug = shout_data.get('slug', '')
topic = (
session.query(Topic)
.join(
ShoutTopic,
and_(
ShoutTopic.topic == Topic.id,
ShoutTopic.shout == shout.id,
ShoutTopic.main == True,
),
)
.first()
)
if topic:
shout_data['main_topic'] = topic
authors = (
session.query(Author)
.join(
ShoutTopic,
and_(
ShoutAuthor.author == Author.id,
ShoutTopic.shout == shout.id,
),
)
.all()
)
if authors:
shout_data['authors'] = authors
score = results_dict.get(shout_slug, {}).get('score', 0)
shout_data = shout.dict() # Convert the Shout instance to a dictionary
shout_data['score'] = score # Add the score to the dictionary
shouts_data.append(shout_data)

View File

@ -138,6 +138,7 @@ type Shout {
published_at: Int
media: String
stat: Stat
score: Float
}
type Stat {