This commit is contained in:
Untone 2025-01-26 17:53:16 +03:00
parent eee2c1a13d
commit 4a26e4f75b
3 changed files with 14 additions and 9 deletions

View File

@ -4,7 +4,7 @@ from sqlalchemy import and_, desc, select
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
from sqlalchemy.sql.functions import coalesce from sqlalchemy.sql.functions import coalesce
from cache.cache import cache_author, cache_topic, invalidate_shouts_cache, invalidate_shout_related_cache from cache.cache import cache_author, cache_topic, invalidate_shout_related_cache, invalidate_shouts_cache
from orm.author import Author from orm.author import Author
from orm.shout import Shout, ShoutAuthor, ShoutTopic from orm.shout import Shout, ShoutAuthor, ShoutTopic
from orm.topic import Topic from orm.topic import Topic
@ -326,9 +326,11 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
shout_input["published_at"] = current_time shout_input["published_at"] = current_time
# Проверяем наличие связи с автором # Проверяем наличие связи с автором
logger.info(f"Checking author link for shout#{shout_id} and author#{author_id}") logger.info(f"Checking author link for shout#{shout_id} and author#{author_id}")
author_link = session.query(ShoutAuthor).filter( author_link = (
and_(ShoutAuthor.shout == shout_id, ShoutAuthor.author == author_id) session.query(ShoutAuthor)
).first() .filter(and_(ShoutAuthor.shout == shout_id, ShoutAuthor.author == author_id))
.first()
)
if not author_link: if not author_link:
logger.info(f"Adding missing author link for shout#{shout_id}") logger.info(f"Adding missing author link for shout#{shout_id}")

View File

@ -1,7 +1,7 @@
import json import json
from graphql import GraphQLResolveInfo from graphql import GraphQLResolveInfo
from sqlalchemy import nulls_last, text, and_ from sqlalchemy import and_, nulls_last, text
from sqlalchemy.orm import aliased from sqlalchemy.orm import aliased
from sqlalchemy.sql.expression import asc, case, desc, func, select from sqlalchemy.sql.expression import asc, case, desc, func, select
@ -472,6 +472,7 @@ async def load_shouts_random_top(_, info, options):
shout = type_("Shout") shout = type_("Shout")
@shout.field("media") @shout.field("media")
def resolve_shout_media(shout, _): def resolve_shout_media(shout, _):
""" """

View File

@ -1,13 +1,14 @@
from asyncio.log import logger from asyncio.log import logger
import httpx import httpx
from ariadne import MutationType, QueryType, ObjectType from ariadne import MutationType, ObjectType, QueryType
from settings import AUTH_URL from settings import AUTH_URL
query = QueryType() query = QueryType()
mutation = MutationType() mutation = MutationType()
def type_(name: str) -> ObjectType: def type_(name: str) -> ObjectType:
""" """
Создает резолвер для объектного типа Создает резолвер для объектного типа
@ -19,6 +20,7 @@ def type_(name: str) -> ObjectType:
resolvers.append(resolver) resolvers.append(resolver)
return resolver return resolver
resolvers = [query, mutation] resolvers = [query, mutation]