From f247e6bd7b7554442493b799780186b916890043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 27 Jun 2023 12:53:47 +0200 Subject: [PATCH] Try to filter only for events with location --- backend/src/schema/resolvers/posts.ts | 9 +++++++-- backend/src/schema/types/type/Location.gql | 8 +++++++- backend/src/schema/types/type/Post.gql | 6 ++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/backend/src/schema/resolvers/posts.ts b/backend/src/schema/resolvers/posts.ts index 0bd4507b5..c4d695e88 100644 --- a/backend/src/schema/resolvers/posts.ts +++ b/backend/src/schema/resolvers/posts.ts @@ -1,6 +1,6 @@ import { v4 as uuid } from 'uuid' import { neo4jgraphql } from 'neo4j-graphql-js' -import { isEmpty } from 'lodash' +import { isEmpty, cloneDeep } from 'lodash' import { UserInputError } from 'apollo-server' import { mergeImage, deleteImage } from './images/images' import Resolver from './helpers/Resolver' @@ -12,12 +12,15 @@ import { createOrUpdateLocations } from './users/location' import CONFIG from '../../config' const maintainPinnedPosts = (params) => { + const filter = cloneDeep(params.filter) const pinnedPostFilter = { pinned: true } if (isEmpty(params.filter)) { params.filter = { OR: [pinnedPostFilter, {}] } } else { - params.filter = { OR: [pinnedPostFilter, { ...params.filter }] } + console.log('maintainPinnedPosts before: ', {...filter}) + params.filter = { OR: [pinnedPostFilter, { ...filter }] } } + console.log('maintainPinnedPosts after: ', {...filter}) return params } @@ -38,6 +41,8 @@ export default { params = await filterForMutedUsers(params, context) params = filterEventDates(params) params = await maintainPinnedPosts(params) + console.log('maintainPinnedPosts filter.OR[1].eventLocation: ', params.filter.OR[1].eventLocation) + console.log('maintainPinnedPosts filter: ', params.filter) return neo4jgraphql(object, params, context, resolveInfo) }, profilePagePosts: async (object, params, context, resolveInfo) => { diff --git a/backend/src/schema/types/type/Location.gql b/backend/src/schema/types/type/Location.gql index fad24cc26..96e2479d2 100644 --- a/backend/src/schema/types/type/Location.gql +++ b/backend/src/schema/types/type/Location.gql @@ -1,3 +1,10 @@ +input _LocationFilter { + NOT: _LocationFilter + id: ID + id_not: ID + name: String +} + type Location { id: ID! name: String! @@ -25,4 +32,3 @@ type LocationMapBox { type Query { queryLocations(place: String!, lang: String!): [LocationMapBox]! } - diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 0a7277515..41525f47e 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -84,8 +84,10 @@ input _PostFilter { group: _GroupFilter postsInMyGroups: Boolean postType_in: [PostType] - eventStart_gte: String - eventEnd_gte: String + eventLocation_not: _LocationFilter + eventLocation: _LocationFilter + eventStart_gte: String + eventEnd_gte: String } enum _PostOrdering {