This commit is contained in:
tonyrewin 2022-06-14 11:33:41 +03:00
parent 9a685590fb
commit 7d26948cc1
5 changed files with 5 additions and 20 deletions

2
.gitignore vendored
View File

@ -140,5 +140,5 @@ migration/content/**/*.md
.obsidian .obsidian
*.zip *.zip
*.sqlite3
.DS_Store .DS_Store

View File

@ -317,7 +317,7 @@ class Shout(Base):
# id = None # id = None
slug: str = Column(String, primary_key=True) slug: str = Column(String, nullable=True, unique=True)
community: int = Column(Integer, ForeignKey("community.id"), nullable=False, comment="Community") community: int = Column(Integer, ForeignKey("community.id"), nullable=False, comment="Community")
body: str = Column(String, nullable=False, comment="Body") body: str = Column(String, nullable=False, comment="Body")
createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at") createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at")

View File

@ -1,7 +1,8 @@
from resolvers.auth import login, sign_out, is_email_free, register, confirm from resolvers.auth import login, sign_out, is_email_free, register, confirm
from resolvers.zine import create_shout, get_shout_by_slug, \ from resolvers.zine import create_shout, get_shout_by_slug, \
top_month, top_overall, recent_published, recent_all, top_viewed, shouts_by_authors, shouts_by_topics, shouts_by_communities, \ top_month, top_overall, recent_published, recent_all, top_viewed, \
shouts_candidates, shouts_reviewed, shouts_subscribed shouts_by_authors, shouts_by_topics, shouts_by_communities, \
shouts_reviewed, shouts_subscribed
from resolvers.profile import get_users_by_slugs, get_current_user from resolvers.profile import get_users_by_slugs, get_current_user
from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \ from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \
topics_by_community, topics_by_slugs topics_by_community, topics_by_slugs
@ -26,7 +27,6 @@ __all__ = [
"shouts_by_communities", "shouts_by_communities",
"shouts_subscribed", "shouts_subscribed",
"shouts_reviewed", "shouts_reviewed",
"shouts_candidates",
"top_month", "top_month",
"top_overall", "top_overall",
"top_viewed", "top_viewed",

View File

@ -482,20 +482,6 @@ async def shouts_reviewed(_, info, page, size):
return shouts return shouts
@query.field("shoutsCandidates")
@login_required
async def shouts_candidates(_, info, size):
user = info.context["request"].user
#TODO: postgres heavy load
with local_session() as session:
shouts = session.query(Shout).distinct().\
outerjoin(ShoutRating).\
where(and_(Shout.publishedAt != None, ShoutRating.rater != user.slug)).\
order_by(desc(Shout.publishedAt)).\
limit(size)
return shouts
@query.field("shoutsCommentedByUser") @query.field("shoutsCommentedByUser")
async def shouts_commented_by_user(_, info, slug, page, size): async def shouts_commented_by_user(_, info, slug, page, size):
user = await UserStorage.get_user_by_slug(slug) user = await UserStorage.get_user_by_slug(slug)

View File

@ -190,7 +190,6 @@ type Query {
shoutsSubscribed(page: Int!, size: Int!): [Shout]! shoutsSubscribed(page: Int!, size: Int!): [Shout]!
shoutsReviewed(page: Int!, size: Int!): [Shout]! shoutsReviewed(page: Int!, size: Int!): [Shout]!
recentCommented(page: Int!, size: Int!): [Shout]! recentCommented(page: Int!, size: Int!): [Shout]!
shoutsCandidates(size: Int = 10): [Shout]!
} }
############################################ Subscription ############################################ Subscription