This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import asyncio
|
||||
import time
|
||||
import traceback
|
||||
from typing import Any, Optional, TypedDict
|
||||
from typing import Any, TypedDict
|
||||
|
||||
from graphql import GraphQLResolveInfo
|
||||
from sqlalchemy import and_, asc, func, select, text
|
||||
@@ -46,18 +46,18 @@ class AuthorsBy(TypedDict, total=False):
|
||||
stat: Поле статистики
|
||||
"""
|
||||
|
||||
last_seen: Optional[int]
|
||||
created_at: Optional[int]
|
||||
slug: Optional[str]
|
||||
name: Optional[str]
|
||||
topic: Optional[str]
|
||||
order: Optional[str]
|
||||
after: Optional[int]
|
||||
stat: Optional[str]
|
||||
last_seen: int | None
|
||||
created_at: int | None
|
||||
slug: str | None
|
||||
name: str | None
|
||||
topic: str | None
|
||||
order: str | None
|
||||
after: int | None
|
||||
stat: str | None
|
||||
|
||||
|
||||
# Вспомогательная функция для получения всех авторов без статистики
|
||||
async def get_all_authors(current_user_id: Optional[int] = None) -> list[Any]:
|
||||
async def get_all_authors(current_user_id: int | None = None) -> list[Any]:
|
||||
"""
|
||||
Получает всех авторов без статистики.
|
||||
Используется для случаев, когда нужен полный список авторов без дополнительной информации.
|
||||
@@ -92,7 +92,7 @@ async def get_all_authors(current_user_id: Optional[int] = None) -> list[Any]:
|
||||
|
||||
# Вспомогательная функция для получения авторов со статистикой с пагинацией
|
||||
async def get_authors_with_stats(
|
||||
limit: int = 10, offset: int = 0, by: Optional[AuthorsBy] = None, current_user_id: Optional[int] = None
|
||||
limit: int = 10, offset: int = 0, by: AuthorsBy | None = None, current_user_id: int | None = None
|
||||
) -> list[dict[str, Any]]:
|
||||
"""
|
||||
Получает авторов со статистикой с пагинацией.
|
||||
@@ -367,7 +367,7 @@ async def get_authors_all(_: None, info: GraphQLResolveInfo) -> list[Any]:
|
||||
|
||||
@query.field("get_author")
|
||||
async def get_author(
|
||||
_: None, info: GraphQLResolveInfo, slug: Optional[str] = None, author_id: Optional[int] = None
|
||||
_: None, info: GraphQLResolveInfo, slug: str | None = None, author_id: int | None = None
|
||||
) -> dict[str, Any] | None:
|
||||
"""Get specific author by slug or ID"""
|
||||
# Получаем ID текущего пользователя и флаг админа из контекста
|
||||
@@ -451,8 +451,8 @@ async def load_authors_search(_: None, info: GraphQLResolveInfo, **kwargs: Any)
|
||||
|
||||
|
||||
def get_author_id_from(
|
||||
slug: Optional[str] = None, user: Optional[str] = None, author_id: Optional[int] = None
|
||||
) -> Optional[int]:
|
||||
slug: str | None = None, user: str | None = None, author_id: int | None = None
|
||||
) -> int | None:
|
||||
"""Get author ID from different identifiers"""
|
||||
try:
|
||||
if author_id:
|
||||
@@ -474,7 +474,7 @@ def get_author_id_from(
|
||||
|
||||
@query.field("get_author_follows")
|
||||
async def get_author_follows(
|
||||
_, info: GraphQLResolveInfo, slug: Optional[str] = None, user: Optional[str] = None, author_id: Optional[int] = None
|
||||
_, info: GraphQLResolveInfo, slug: str | None = None, user: str | None = None, author_id: int | None = None
|
||||
) -> dict[str, Any]:
|
||||
"""Get entities followed by author"""
|
||||
# Получаем ID текущего пользователя и флаг админа из контекста
|
||||
@@ -519,9 +519,9 @@ async def get_author_follows(
|
||||
async def get_author_follows_topics(
|
||||
_,
|
||||
_info: GraphQLResolveInfo,
|
||||
slug: Optional[str] = None,
|
||||
user: Optional[str] = None,
|
||||
author_id: Optional[int] = None,
|
||||
slug: str | None = None,
|
||||
user: str | None = None,
|
||||
author_id: int | None = None,
|
||||
) -> list[Any]:
|
||||
"""Get topics followed by author"""
|
||||
logger.debug(f"getting followed topics for @{slug}")
|
||||
@@ -537,7 +537,7 @@ async def get_author_follows_topics(
|
||||
|
||||
@query.field("get_author_follows_authors")
|
||||
async def get_author_follows_authors(
|
||||
_, info: GraphQLResolveInfo, slug: Optional[str] = None, user: Optional[str] = None, author_id: Optional[int] = None
|
||||
_, info: GraphQLResolveInfo, slug: str | None = None, user: str | None = None, author_id: int | None = None
|
||||
) -> list[Any]:
|
||||
"""Get authors followed by author"""
|
||||
# Получаем ID текущего пользователя и флаг админа из контекста
|
||||
|
||||
Reference in New Issue
Block a user