From 56e4700acee955c1167387f7af3bad0d4082c937 Mon Sep 17 00:00:00 2001 From: bniwredyc Date: Fri, 5 May 2023 00:59:04 +0200 Subject: [PATCH] resetdb update (v2), loadDrafts --- resetdb.sh | 4 ++-- resolvers/zine/load.py | 14 ++------------ schema.graphql | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/resetdb.sh b/resetdb.sh index ead9247c..39b3b9b2 100644 --- a/resetdb.sh +++ b/resetdb.sh @@ -1,7 +1,7 @@ database_name="discoursio" -remote_backup_dir="/var/backups/mongodb_primero" +remote_backup_dir="/var/backups/mongodb" user="root" -host="testapi.discours.io" +host="v2.discours.io" server="$user@$host" dump_dir="./dump" local_backup_filename="discours-backup.bson.gz.tar" diff --git a/resolvers/zine/load.py b/resolvers/zine/load.py index 90315b63..19a250b8 100644 --- a/resolvers/zine/load.py +++ b/resolvers/zine/load.py @@ -196,7 +196,7 @@ async def load_shouts_by(_, info, options): return shouts @query.field("loadDrafts") -async def get_drafts(_, info, options): +async def get_drafts(_, info): auth: AuthCredentials = info.context["request"].auth user_id = auth.user_id @@ -207,17 +207,7 @@ async def get_drafts(_, info, options): and_(Shout.deletedAt.is_(None), Shout.createdBy == user_id) ) - q = apply_filters(q, options.get("filters", {}), user_id) - order_by = options.get("order_by", Shout.createdAt) - if order_by == 'reacted': - aliased_reaction = aliased(Reaction) - q.outerjoin(aliased_reaction).add_columns(func.max(aliased_reaction.createdAt).label('reacted')) - - query_order_by = desc(order_by) if options.get('order_by_desc', True) else asc(order_by) - offset = options.get("offset", 0) - limit = options.get("limit", 10) - - q = q.group_by(Shout.id).order_by(query_order_by).limit(limit).offset(offset) + q = q.group_by(Shout.id) shouts = [] with local_session() as session: diff --git a/schema.graphql b/schema.graphql index 7c75a79d..a56bd52b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -278,7 +278,7 @@ type Query { loadAuthorsBy(by: AuthorsBy, limit: Int, offset: Int): [Author]! loadShout(slug: String!): Shout loadShouts(options: LoadShoutsOptions): [Shout]! - loadDrafts(options: LoadShoutsOptions): [Shout]! + loadDrafts: [Shout]! loadReactionsBy(by: ReactionBy!, limit: Int, offset: Int): [Reaction]! userFollowers(slug: String!): [Author]! userFollowedAuthors(slug: String!): [Author]!