mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
count clicks on posts setup
This commit is contained in:
parent
dabc36d1b3
commit
7bbdd5852f
@ -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',
|
||||
|
||||
14
backend/src/middleware/userInteractions.js
Normal file
14
backend/src/middleware/userInteractions.js
Normal 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,
|
||||
},
|
||||
}
|
||||
@ -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:
|
||||
|
||||
@ -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)")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user