count clicks on posts setup

This commit is contained in:
Moriz Wahl 2021-02-15 17:00:31 +01:00
parent dabc36d1b3
commit 7bbdd5852f
4 changed files with 22 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import hashtags from './hashtags/hashtagsMiddleware'
import email from './email/emailMiddleware'
import sentry from './sentryMiddleware'
import languages from './languages/languages'
import userInteractions from './userInteractions'
export default (schema) => {
const middlewares = {
@ -32,6 +33,7 @@ export default (schema) => {
includedFields,
orderBy,
languages,
userInteractions,
}
let order = [
@ -40,6 +42,7 @@ export default (schema) => {
'xss',
// 'activityPub', disabled temporarily
'validation',
'userInteractions',
'sluggify',
'languages',
'excerpt',

View File

@ -0,0 +1,14 @@
const userClickedPost = async (resolve, root, args, context, info) => {
if (args.id) {
console.log('post clicked--', args.id)
}
return resolve(root, args, context, info)
}
export default {
Query: {
Post: userClickedPost,
},
}

View File

@ -337,6 +337,7 @@ export default {
shoutedCount:
'<-[:SHOUTED]-(related:User) WHERE NOT related.deleted = true AND NOT related.disabled = true',
emotionsCount: '<-[related:EMOTED]-(:User)',
clickedCount: '<-[related:CLICKED]-(:User)',
},
boolean: {
shoutedByCurrentUser:

View File

@ -156,6 +156,10 @@ type Post {
statement: "MATCH (this)<-[:SHOUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1"
)
clickedCount: Int!
@cypher(
statement: "MATCH (this)<-[:CLICKED]-(r:User) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)"
)
emotions: [EMOTED]
emotionsCount: Int!
@cypher(statement: "MATCH (this)<-[emoted:EMOTED]-(:User) RETURN COUNT(DISTINCT emoted)")