diff --git a/.gitignore b/.gitignore index 17aee341..6c6dd38c 100644 --- a/.gitignore +++ b/.gitignore @@ -140,5 +140,5 @@ migration/content/**/*.md .obsidian *.zip - +*.sqlite3 .DS_Store \ No newline at end of file diff --git a/orm/shout.py b/orm/shout.py index 7b7be84b..afdc6191 100644 --- a/orm/shout.py +++ b/orm/shout.py @@ -317,7 +317,7 @@ class Shout(Base): # 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") body: str = Column(String, nullable=False, comment="Body") createdAt: str = Column(DateTime, nullable=False, default = datetime.now, comment="Created at") diff --git a/resolvers/__init__.py b/resolvers/__init__.py index 86b097a1..70882516 100644 --- a/resolvers/__init__.py +++ b/resolvers/__init__.py @@ -1,7 +1,8 @@ from resolvers.auth import login, sign_out, is_email_free, register, confirm 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, \ - shouts_candidates, shouts_reviewed, shouts_subscribed + top_month, top_overall, recent_published, recent_all, top_viewed, \ + 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.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \ topics_by_community, topics_by_slugs @@ -26,7 +27,6 @@ __all__ = [ "shouts_by_communities", "shouts_subscribed", "shouts_reviewed", - "shouts_candidates", "top_month", "top_overall", "top_viewed", diff --git a/resolvers/zine.py b/resolvers/zine.py index ac044378..c0ed8a0a 100644 --- a/resolvers/zine.py +++ b/resolvers/zine.py @@ -482,20 +482,6 @@ async def shouts_reviewed(_, info, page, size): 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") async def shouts_commented_by_user(_, info, slug, page, size): user = await UserStorage.get_user_by_slug(slug) diff --git a/schema.graphql b/schema.graphql index f082efa5..30d997b1 100644 --- a/schema.graphql +++ b/schema.graphql @@ -190,7 +190,6 @@ type Query { shoutsSubscribed(page: Int!, size: Int!): [Shout]! shoutsReviewed(page: Int!, size: Int!): [Shout]! recentCommented(page: Int!, size: Int!): [Shout]! - shoutsCandidates(size: Int = 10): [Shout]! } ############################################ Subscription