This commit is contained in:
@@ -12,12 +12,7 @@ from resolvers.author import (
|
||||
)
|
||||
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,
|
||||
@@ -41,12 +36,7 @@ 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()
|
||||
|
@@ -8,12 +8,7 @@ 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
|
||||
|
@@ -53,9 +53,12 @@ def apply_filters(q, filters, author_id=None):
|
||||
if filters.get("reacted"):
|
||||
q.join(Reaction, Reaction.created_by == author_id)
|
||||
|
||||
by_featured = filters.get("featured")
|
||||
if by_featured:
|
||||
q = q.filter(Shout.featured_at.is_not(None))
|
||||
by_featured = filters.get("featured", "not set")
|
||||
if isinstance(by_featured, bool):
|
||||
if by_featured:
|
||||
q = q.filter(Shout.featured_at.is_not(None))
|
||||
else:
|
||||
q = q.filter(Shout.featured_at.is_(None))
|
||||
by_layouts = filters.get("layouts")
|
||||
if by_layouts:
|
||||
q = q.filter(Shout.layout.in_(by_layouts))
|
||||
|
@@ -16,9 +16,7 @@ def add_topic_stat_columns(q):
|
||||
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
|
||||
)
|
||||
aliased_follower = aliased(TopicFollower)
|
||||
q = q.outerjoin(
|
||||
aliased_follower, aliased_follower.topic == Topic.id
|
||||
).add_columns(
|
||||
q = q.outerjoin(aliased_follower, aliased_follower.topic == Topic.id).add_columns(
|
||||
func.count(distinct(aliased_follower.follower)).label("followers_stat")
|
||||
)
|
||||
|
||||
@@ -27,8 +25,6 @@ def add_topic_stat_columns(q):
|
||||
return q
|
||||
|
||||
|
||||
|
||||
|
||||
def add_author_stat_columns(q):
|
||||
aliased_shout = aliased(ShoutAuthor)
|
||||
q = q.outerjoin(aliased_shout).add_columns(
|
||||
@@ -116,6 +112,7 @@ def get_topic_comments_stat(topic_id: int):
|
||||
result = local_session().execute(q).first()
|
||||
return result[0] if result else 0
|
||||
|
||||
|
||||
def get_author_shouts_stat(author_id: int):
|
||||
aliased_shout_author = aliased(ShoutAuthor)
|
||||
q = select(func.count(distinct(aliased_shout_author.shout))).filter(
|
||||
|
Reference in New Issue
Block a user