viwed-fix+fmt+outerjoin-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m1s
All checks were successful
Deploy on push / deploy (push) Successful in 1m1s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from resolvers.author import (
|
||||
from resolvers.author import ( # search_authors,
|
||||
get_author,
|
||||
get_author_followers,
|
||||
get_author_follows,
|
||||
@@ -7,12 +7,16 @@ from resolvers.author import (
|
||||
get_author_id,
|
||||
get_authors_all,
|
||||
load_authors_by,
|
||||
search_authors,
|
||||
update_author,
|
||||
)
|
||||
from resolvers.community import get_communities_all, get_community
|
||||
from resolvers.editor import create_shout, delete_shout, update_shout
|
||||
from resolvers.follower import follow, get_shout_followers, get_topic_followers, unfollow
|
||||
from resolvers.follower import (
|
||||
follow,
|
||||
get_shout_followers,
|
||||
get_topic_followers,
|
||||
unfollow,
|
||||
)
|
||||
from resolvers.notifier import (
|
||||
load_notifications,
|
||||
notification_mark_seen,
|
||||
@@ -36,7 +40,12 @@ from resolvers.reader import (
|
||||
load_shouts_search,
|
||||
load_shouts_unrated,
|
||||
)
|
||||
from resolvers.topic import get_topic, get_topics_all, get_topics_by_author, get_topics_by_community
|
||||
from resolvers.topic import (
|
||||
get_topic,
|
||||
get_topics_all,
|
||||
get_topics_by_author,
|
||||
get_topics_by_community,
|
||||
)
|
||||
from services.triggers import events_register
|
||||
|
||||
events_register()
|
||||
@@ -52,7 +61,7 @@ __all__ = [
|
||||
"load_authors_by",
|
||||
"rate_author",
|
||||
"update_author",
|
||||
"search_authors",
|
||||
## "search_authors",
|
||||
# community
|
||||
"get_community",
|
||||
"get_communities_all",
|
||||
|
@@ -3,7 +3,6 @@ import time
|
||||
|
||||
from sqlalchemy import and_, desc, or_, select, text
|
||||
from sqlalchemy.orm import aliased
|
||||
from sqlalchemy_searchable import search
|
||||
|
||||
from orm.author import Author, AuthorFollower
|
||||
from orm.shout import ShoutAuthor, ShoutTopic
|
||||
@@ -323,9 +322,3 @@ async def get_author_followers(_, _info, slug: str):
|
||||
logger.error(exc)
|
||||
logger.error(traceback.format_exc())
|
||||
return []
|
||||
|
||||
|
||||
@query.field("search_authors")
|
||||
async def search_authors(_, _info, what: str):
|
||||
q = search(select(Author), what)
|
||||
return get_with_stat(q)
|
||||
|
@@ -8,7 +8,12 @@ from sqlalchemy.orm import aliased
|
||||
from sqlalchemy.sql import not_
|
||||
|
||||
from orm.author import Author
|
||||
from orm.notification import Notification, NotificationAction, NotificationEntity, NotificationSeen
|
||||
from orm.notification import (
|
||||
Notification,
|
||||
NotificationAction,
|
||||
NotificationEntity,
|
||||
NotificationSeen,
|
||||
)
|
||||
from orm.shout import Shout
|
||||
from services.auth import login_required
|
||||
from services.db import local_session
|
||||
|
@@ -172,24 +172,23 @@ def get_with_stat(q):
|
||||
is_author = f"{q}".lower().startswith("select author")
|
||||
# is_topic = f"{q}".lower().startswith("select topic")
|
||||
result = []
|
||||
add_stat_handler = (
|
||||
add_author_stat_columns if is_author else add_topic_stat_columns
|
||||
)
|
||||
if is_author:
|
||||
q = add_author_stat_columns(q)
|
||||
else:
|
||||
q = add_topic_stat_columns(q)
|
||||
with local_session() as session:
|
||||
result = session.execute(add_stat_handler(q))
|
||||
result = session.execute(q)
|
||||
|
||||
for cols in result:
|
||||
entity = cols[0]
|
||||
stat = dict()
|
||||
stat["shouts"] = cols[1]
|
||||
stat["followers"] = cols[2]
|
||||
stat["authors"] = (
|
||||
get_author_authors_stat(entity.id)
|
||||
if is_author
|
||||
else get_topic_authors_stat(entity.id)
|
||||
)
|
||||
if is_author:
|
||||
stat["authors"] = get_author_authors_stat(entity.id)
|
||||
stat["comments"] = get_author_comments_stat(entity.id)
|
||||
else:
|
||||
stat["authors"] = get_topic_authors_stat(entity.id)
|
||||
entity.stat = stat
|
||||
records.append(entity)
|
||||
except Exception as exc:
|
||||
|
Reference in New Issue
Block a user