migration, auth, refactoring, formatting
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
from typing import List
|
||||
|
||||
from sqlalchemy import and_, desc
|
||||
|
||||
from auth.authenticate import login_required
|
||||
from base.orm import local_session
|
||||
from base.resolvers import query
|
||||
from sqlalchemy import and_, desc
|
||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
from orm.topic import TopicFollower
|
||||
from orm.user import AuthorFollower
|
||||
from typing import List
|
||||
from services.zine.shoutscache import prepare_shouts
|
||||
|
||||
|
||||
@@ -22,14 +24,14 @@ def get_user_feed(_, info, offset, limit) -> List[Shout]:
|
||||
.where(AuthorFollower.follower == user.slug)
|
||||
.order_by(desc(Shout.createdAt))
|
||||
)
|
||||
topicrows = (
|
||||
topic_rows = (
|
||||
session.query(Shout)
|
||||
.join(ShoutTopic)
|
||||
.join(TopicFollower)
|
||||
.where(TopicFollower.follower == user.slug)
|
||||
.order_by(desc(Shout.createdAt))
|
||||
)
|
||||
shouts = shouts.union(topicrows).limit(limit).offset(offset).all()
|
||||
shouts = shouts.union(topic_rows).limit(limit).offset(offset).all()
|
||||
return shouts
|
||||
|
||||
|
||||
@@ -37,7 +39,6 @@ def get_user_feed(_, info, offset, limit) -> List[Shout]:
|
||||
@login_required
|
||||
async def user_unpublished_shouts(_, info, offset, limit) -> List[Shout]:
|
||||
user = info.context["request"].user
|
||||
shouts = []
|
||||
with local_session() as session:
|
||||
shouts = prepare_shouts(
|
||||
session.query(Shout)
|
||||
@@ -48,4 +49,4 @@ async def user_unpublished_shouts(_, info, offset, limit) -> List[Shout]:
|
||||
.offset(offset)
|
||||
.all()
|
||||
)
|
||||
return shouts
|
||||
return shouts
|
||||
|
Reference in New Issue
Block a user