fmt
This commit is contained in:
parent
eee2c1a13d
commit
4a26e4f75b
|
@ -4,7 +4,7 @@ from sqlalchemy import and_, desc, select
|
|||
from sqlalchemy.orm import joinedload
|
||||
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.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
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
|
||||
# Проверяем наличие связи с автором
|
||||
logger.info(f"Checking author link for shout#{shout_id} and author#{author_id}")
|
||||
author_link = session.query(ShoutAuthor).filter(
|
||||
and_(ShoutAuthor.shout == shout_id, ShoutAuthor.author == author_id)
|
||||
).first()
|
||||
author_link = (
|
||||
session.query(ShoutAuthor)
|
||||
.filter(and_(ShoutAuthor.shout == shout_id, ShoutAuthor.author == author_id))
|
||||
.first()
|
||||
)
|
||||
|
||||
if not author_link:
|
||||
logger.info(f"Adding missing author link for shout#{shout_id}")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
|
||||
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.sql.expression import asc, case, desc, func, select
|
||||
|
||||
|
@ -472,6 +472,7 @@ async def load_shouts_random_top(_, info, options):
|
|||
|
||||
shout = type_("Shout")
|
||||
|
||||
|
||||
@shout.field("media")
|
||||
def resolve_shout_media(shout, _):
|
||||
"""
|
||||
|
@ -480,7 +481,7 @@ def resolve_shout_media(shout, _):
|
|||
"""
|
||||
if not shout.media:
|
||||
return []
|
||||
|
||||
|
||||
# Если media это строка JSON, парсим её
|
||||
if isinstance(shout.media, str):
|
||||
try:
|
||||
|
@ -489,7 +490,7 @@ def resolve_shout_media(shout, _):
|
|||
return []
|
||||
else:
|
||||
media_data = shout.media
|
||||
|
||||
|
||||
# Если media_data это словарь, оборачиваем его в список
|
||||
if isinstance(media_data, dict):
|
||||
return [media_data]
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
from asyncio.log import logger
|
||||
|
||||
import httpx
|
||||
from ariadne import MutationType, QueryType, ObjectType
|
||||
from ariadne import MutationType, ObjectType, QueryType
|
||||
|
||||
from settings import AUTH_URL
|
||||
|
||||
query = QueryType()
|
||||
mutation = MutationType()
|
||||
|
||||
|
||||
def type_(name: str) -> ObjectType:
|
||||
"""
|
||||
Создает резолвер для объектного типа
|
||||
|
||||
|
||||
:param name: Имя типа в схеме GraphQL
|
||||
:return: Резолвер объектного типа
|
||||
"""
|
||||
|
@ -19,6 +20,7 @@ def type_(name: str) -> ObjectType:
|
|||
resolvers.append(resolver)
|
||||
return resolver
|
||||
|
||||
|
||||
resolvers = [query, mutation]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user