Skip to content

Commit

Permalink
Try to filter only for events with location
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirokk committed Jun 27, 2023
1 parent f06369a commit f247e6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions backend/src/schema/resolvers/posts.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
}

Expand All @@ -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) => {
Expand Down
8 changes: 7 additions & 1 deletion backend/src/schema/types/type/Location.gql
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
input _LocationFilter {
NOT: _LocationFilter
id: ID
id_not: ID
name: String
}

type Location {
id: ID!
name: String!
Expand Down Expand Up @@ -25,4 +32,3 @@ type LocationMapBox {
type Query {
queryLocations(place: String!, lang: String!): [LocationMapBox]!
}

6 changes: 4 additions & 2 deletions backend/src/schema/types/type/Post.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f247e6b

Please sign in to comment.