sqlsynt2
This commit is contained in:
parent
3a5449df79
commit
e9f9582110
|
@ -51,17 +51,15 @@ async def get_my_rates_shouts(_, info, shouts):
|
||||||
author_dict = info.context.get("author") if info.context else None
|
author_dict = info.context.get("author") if info.context else None
|
||||||
author_id = author_dict.get("id") if author_dict else None
|
author_id = author_dict.get("id") if author_dict else None
|
||||||
|
|
||||||
# Возвращаем пустой список вместо None/error
|
|
||||||
if not author_id:
|
if not author_id:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
try:
|
try:
|
||||||
result = session.execute(
|
stmt = (
|
||||||
select([
|
select(
|
||||||
Reaction.shout.label("shout_id"),
|
Reaction
|
||||||
Reaction.kind.label("my_rate")
|
).where(
|
||||||
]).where(
|
|
||||||
and_(
|
and_(
|
||||||
Reaction.shout.in_(shouts),
|
Reaction.shout.in_(shouts),
|
||||||
Reaction.reply_to.is_(None),
|
Reaction.reply_to.is_(None),
|
||||||
|
@ -73,14 +71,18 @@ async def get_my_rates_shouts(_, info, shouts):
|
||||||
Reaction.shout,
|
Reaction.shout,
|
||||||
Reaction.created_at.desc()
|
Reaction.created_at.desc()
|
||||||
).distinct(Reaction.shout)
|
).distinct(Reaction.shout)
|
||||||
).all()
|
)
|
||||||
|
|
||||||
|
result = session.execute(stmt).all()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{"shout_id": row.shout_id, "my_rate": row.my_rate}
|
{
|
||||||
|
"shout_id": row[0].shout, # Получаем shout_id из объекта Reaction
|
||||||
|
"my_rate": row[0].kind # Получаем kind (my_rate) из объекта Reaction
|
||||||
|
}
|
||||||
for row in result
|
for row in result
|
||||||
]
|
]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# В случае ошибки тоже возвращаем пустой список
|
|
||||||
logger.error(f"Error in get_my_rates_shouts: {e}")
|
logger.error(f"Error in get_my_rates_shouts: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user