This commit is contained in:
parent
e68196ce0b
commit
27d5272032
|
@ -35,3 +35,9 @@ build-backend = "poetry.core.masonry.api"
|
|||
[tool.pyright]
|
||||
venvPath = "."
|
||||
venv = ".venv"
|
||||
|
||||
[tool.isort]
|
||||
multi_line_output = 3
|
||||
include_trailing_comma = true
|
||||
force_grid_wrap = 0
|
||||
line_length = 120
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -7,12 +7,7 @@ from typing import Dict
|
|||
|
||||
# ga
|
||||
from google.analytics.data_v1beta import BetaAnalyticsDataClient
|
||||
from google.analytics.data_v1beta.types import (
|
||||
DateRange,
|
||||
Dimension,
|
||||
Metric,
|
||||
RunReportRequest,
|
||||
)
|
||||
from google.analytics.data_v1beta.types import DateRange, Dimension, Metric, RunReportRequest
|
||||
|
||||
from orm.author import Author
|
||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
|
|
Loading…
Reference in New Issue
Block a user