This commit is contained in:
parent
e68196ce0b
commit
27d5272032
|
@ -35,3 +35,9 @@ build-backend = "poetry.core.masonry.api"
|
||||||
[tool.pyright]
|
[tool.pyright]
|
||||||
venvPath = "."
|
venvPath = "."
|
||||||
venv = ".venv"
|
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.community import get_communities_all, get_community
|
||||||
from resolvers.editor import create_shout, delete_shout, update_shout
|
from resolvers.editor import create_shout, delete_shout, update_shout
|
||||||
from resolvers.follower import (
|
from resolvers.follower import follow, get_shout_followers, get_topic_followers, unfollow
|
||||||
follow,
|
|
||||||
get_shout_followers,
|
|
||||||
get_topic_followers,
|
|
||||||
unfollow,
|
|
||||||
)
|
|
||||||
from resolvers.notifier import (
|
from resolvers.notifier import (
|
||||||
load_notifications,
|
load_notifications,
|
||||||
notification_mark_seen,
|
notification_mark_seen,
|
||||||
|
@ -41,12 +36,7 @@ from resolvers.reader import (
|
||||||
load_shouts_search,
|
load_shouts_search,
|
||||||
load_shouts_unrated,
|
load_shouts_unrated,
|
||||||
)
|
)
|
||||||
from resolvers.topic import (
|
from resolvers.topic import get_topic, get_topics_all, get_topics_by_author, get_topics_by_community
|
||||||
get_topic,
|
|
||||||
get_topics_all,
|
|
||||||
get_topics_by_author,
|
|
||||||
get_topics_by_community,
|
|
||||||
)
|
|
||||||
from services.triggers import events_register
|
from services.triggers import events_register
|
||||||
|
|
||||||
events_register()
|
events_register()
|
||||||
|
|
|
@ -8,12 +8,7 @@ from sqlalchemy.orm import aliased
|
||||||
from sqlalchemy.sql import not_
|
from sqlalchemy.sql import not_
|
||||||
|
|
||||||
from orm.author import Author
|
from orm.author import Author
|
||||||
from orm.notification import (
|
from orm.notification import Notification, NotificationAction, NotificationEntity, NotificationSeen
|
||||||
Notification,
|
|
||||||
NotificationAction,
|
|
||||||
NotificationEntity,
|
|
||||||
NotificationSeen,
|
|
||||||
)
|
|
||||||
from orm.shout import Shout
|
from orm.shout import Shout
|
||||||
from services.auth import login_required
|
from services.auth import login_required
|
||||||
from services.db import local_session
|
from services.db import local_session
|
||||||
|
|
|
@ -53,9 +53,12 @@ def apply_filters(q, filters, author_id=None):
|
||||||
if filters.get("reacted"):
|
if filters.get("reacted"):
|
||||||
q.join(Reaction, Reaction.created_by == author_id)
|
q.join(Reaction, Reaction.created_by == author_id)
|
||||||
|
|
||||||
by_featured = filters.get("featured")
|
by_featured = filters.get("featured", "not set")
|
||||||
if by_featured:
|
if isinstance(by_featured, bool):
|
||||||
q = q.filter(Shout.featured_at.is_not(None))
|
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")
|
by_layouts = filters.get("layouts")
|
||||||
if by_layouts:
|
if by_layouts:
|
||||||
q = q.filter(Shout.layout.in_(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")
|
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
|
||||||
)
|
)
|
||||||
aliased_follower = aliased(TopicFollower)
|
aliased_follower = aliased(TopicFollower)
|
||||||
q = q.outerjoin(
|
q = q.outerjoin(aliased_follower, aliased_follower.topic == Topic.id).add_columns(
|
||||||
aliased_follower, aliased_follower.topic == Topic.id
|
|
||||||
).add_columns(
|
|
||||||
func.count(distinct(aliased_follower.follower)).label("followers_stat")
|
func.count(distinct(aliased_follower.follower)).label("followers_stat")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,8 +25,6 @@ def add_topic_stat_columns(q):
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_author_stat_columns(q):
|
def add_author_stat_columns(q):
|
||||||
aliased_shout = aliased(ShoutAuthor)
|
aliased_shout = aliased(ShoutAuthor)
|
||||||
q = q.outerjoin(aliased_shout).add_columns(
|
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()
|
result = local_session().execute(q).first()
|
||||||
return result[0] if result else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
def get_author_shouts_stat(author_id: int):
|
def get_author_shouts_stat(author_id: int):
|
||||||
aliased_shout_author = aliased(ShoutAuthor)
|
aliased_shout_author = aliased(ShoutAuthor)
|
||||||
q = select(func.count(distinct(aliased_shout_author.shout))).filter(
|
q = select(func.count(distinct(aliased_shout_author.shout))).filter(
|
||||||
|
|
|
@ -7,12 +7,7 @@ from typing import Dict
|
||||||
|
|
||||||
# ga
|
# ga
|
||||||
from google.analytics.data_v1beta import BetaAnalyticsDataClient
|
from google.analytics.data_v1beta import BetaAnalyticsDataClient
|
||||||
from google.analytics.data_v1beta.types import (
|
from google.analytics.data_v1beta.types import DateRange, Dimension, Metric, RunReportRequest
|
||||||
DateRange,
|
|
||||||
Dimension,
|
|
||||||
Metric,
|
|
||||||
RunReportRequest,
|
|
||||||
)
|
|
||||||
|
|
||||||
from orm.author import Author
|
from orm.author import Author
|
||||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||||
|
|
Loading…
Reference in New Issue
Block a user