fmt
All checks were successful
Deploy on push / deploy (push) Successful in 7s

This commit is contained in:
Untone 2024-12-11 23:02:14 +03:00
parent c5d21c3554
commit fbcee18db1
6 changed files with 21 additions and 29 deletions

View File

@ -56,20 +56,18 @@ async def get_my_rates_shouts(_, info, shouts):
with local_session() as session:
try:
stmt = (
select(
Reaction
).where(
select(Reaction)
.where(
and_(
Reaction.shout.in_(shouts),
Reaction.reply_to.is_(None),
Reaction.created_by == author_id,
Reaction.deleted_at.is_(None),
Reaction.kind.in_([ReactionKind.LIKE.value, ReactionKind.DISLIKE.value])
Reaction.kind.in_([ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]),
)
).order_by(
Reaction.shout,
Reaction.created_at.desc()
).distinct(Reaction.shout)
)
.order_by(Reaction.shout, Reaction.created_at.desc())
.distinct(Reaction.shout)
)
result = session.execute(stmt).all()
@ -77,7 +75,7 @@ async def get_my_rates_shouts(_, info, shouts):
return [
{
"shout_id": row[0].shout, # Получаем shout_id из объекта Reaction
"my_rate": row[0].kind # Получаем kind (my_rate) из объекта Reaction
"my_rate": row[0].kind, # Получаем kind (my_rate) из объекта Reaction
}
for row in result
]

View File

@ -161,9 +161,9 @@ def query_with_stat(info):
)
.filter(Reaction.reply_to.is_(None))
.label("rating"),
func.max(Reaction.created_at).filter(Reaction.kind == ReactionKind.COMMENT.value).label(
"last_commented_at"
),
func.max(Reaction.created_at)
.filter(Reaction.kind == ReactionKind.COMMENT.value)
.label("last_commented_at"),
)
.where(Reaction.deleted_at.is_(None))
.group_by(Reaction.shout)
@ -177,7 +177,7 @@ def query_with_stat(info):
"rating",
func.coalesce(stats_subquery.c.rating, 0),
"last_commented_at",
func.coalesce(stats_subquery.c.last_commented_at, 0)
func.coalesce(stats_subquery.c.last_commented_at, 0),
).label("stat")
)

View File

@ -1,7 +1,5 @@
from functools import wraps
import httpx
from cache.cache import get_cached_author_by_user_id
from resolvers.stat import get_with_stat
from services.schema import request_graphql_data

View File

@ -226,5 +226,6 @@ async def search_text(text: str, limit: int = 50, offset: int = 0):
payload = await search_service.search(text, limit, offset)
return payload
# Проверить что URL корректный
OPENSEARCH_URL = os.getenv('OPENSEARCH_URL', 'rc1a-3n5pi3bhuj9gieel.mdb.yandexcloud.net')
OPENSEARCH_URL = os.getenv("OPENSEARCH_URL", "rc1a-3n5pi3bhuj9gieel.mdb.yandexcloud.net")

View File

@ -27,9 +27,7 @@ async def check_webhook_existence() -> bool:
operation = "GetWebhooks"
query_name = "_webhooks"
variables = {
"params": {}
}
variables = {"params": {}}
# https://docs.authorizer.dev/core/graphql-api#_webhooks
gql = {
"query": f"query {operation}($params: GetWebhooksRequest!)"
@ -64,9 +62,7 @@ async def create_webhook_endpoint():
"event_name": "user.login",
"endpoint": "https://core.dscrs.site/new-author",
"enabled": True,
"headers": {
"Authorization": WEBHOOK_SECRET
},
"headers": {"Authorization": WEBHOOK_SECRET},
}
}
gql = {
@ -76,7 +72,6 @@ async def create_webhook_endpoint():
+ "}",
"variables": variables,
"operationName": operation,
}
result = await request_graphql_data(gql, headers=headers)
logger.info(result)