mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Add locations to seeds, fix shoutedByCurrentUser
This commit is contained in:
parent
00454c874c
commit
64268a1f3c
21
backend/src/models/Location.js
Normal file
21
backend/src/models/Location.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
id: { type: 'string', primary: true },
|
||||
lat: { type: 'number' },
|
||||
lng: { type: 'number' },
|
||||
type: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
nameES: { type: 'string' },
|
||||
nameFR: { type: 'string' },
|
||||
nameIT: { type: 'string' },
|
||||
nameEN: { type: 'string' },
|
||||
namePT: { type: 'string' },
|
||||
nameDE: { type: 'string' },
|
||||
nameNL: { type: 'string' },
|
||||
namePL: { type: 'string' },
|
||||
isIn: {
|
||||
type: 'relationship',
|
||||
relationship: 'IS_IN',
|
||||
target: 'Location',
|
||||
direction: 'out',
|
||||
},
|
||||
}
|
||||
@ -89,4 +89,10 @@ module.exports = {
|
||||
target: 'Post',
|
||||
direction: 'out',
|
||||
},
|
||||
isIn: {
|
||||
type: 'relationship',
|
||||
relationship: 'IS_IN',
|
||||
target: 'Location',
|
||||
direction: 'out',
|
||||
},
|
||||
}
|
||||
|
||||
@ -10,4 +10,5 @@ export default {
|
||||
Comment: require('./Comment.js'),
|
||||
Category: require('./Category.js'),
|
||||
Tag: require('./Tag.js'),
|
||||
Location: require('./Location.js'),
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ export default {
|
||||
},
|
||||
boolean: {
|
||||
shoutedByCurrentUser:
|
||||
'<-[:SHOUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||
'MATCH(this)<-[:SHOUTED]-(related:User {id: $cypherParams.currentUserId}) RETURN COUNT(related) >= 1',
|
||||
},
|
||||
}),
|
||||
relatedContributions: async (parent, params, context, resolveInfo) => {
|
||||
|
||||
17
backend/src/schema/types/Location.gql
Normal file
17
backend/src/schema/types/Location.gql
Normal file
@ -0,0 +1,17 @@
|
||||
type Location {
|
||||
id: ID!
|
||||
name: String!
|
||||
nameEN: String
|
||||
nameDE: String
|
||||
nameFR: String
|
||||
nameNL: String
|
||||
nameIT: String
|
||||
nameES: String
|
||||
namePT: String
|
||||
namePL: String
|
||||
type: String!
|
||||
lat: Float
|
||||
lng: Float
|
||||
parent: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
||||
}
|
||||
|
||||
@ -51,23 +51,6 @@ type Statistics {
|
||||
countShouts: Int!
|
||||
}
|
||||
|
||||
type Location {
|
||||
id: ID!
|
||||
name: String!
|
||||
nameEN: String
|
||||
nameDE: String
|
||||
nameFR: String
|
||||
nameNL: String
|
||||
nameIT: String
|
||||
nameES: String
|
||||
namePT: String
|
||||
namePL: String
|
||||
type: String!
|
||||
lat: Float
|
||||
lng: Float
|
||||
parent: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
||||
}
|
||||
|
||||
type Report {
|
||||
id: ID!
|
||||
submitter: User @relation(name: "REPORTED", direction: "IN")
|
||||
|
||||
@ -43,10 +43,7 @@ type Post {
|
||||
# Has the currently logged in user shouted that post?
|
||||
shoutedByCurrentUser: Boolean!
|
||||
@cypher(
|
||||
statement: """
|
||||
MATCH (this)<-[:SHOUTED]-(u:User {id: $cypherParams.currentUserId})
|
||||
RETURN COUNT(u) >= 1
|
||||
"""
|
||||
statement: "MATCH (this)<-[:SHOUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1"
|
||||
)
|
||||
|
||||
emotions: [EMOTED]
|
||||
|
||||
@ -7,6 +7,7 @@ import createComment from './comments.js'
|
||||
import createCategory from './categories.js'
|
||||
import createTag from './tags.js'
|
||||
import createSocialMedia from './socialMedia.js'
|
||||
import createLocation from './locations.js'
|
||||
|
||||
export const seedServerHost = 'http://127.0.0.1:4001'
|
||||
|
||||
@ -28,6 +29,7 @@ const factories = {
|
||||
Category: createCategory,
|
||||
Tag: createTag,
|
||||
SocialMedia: createSocialMedia,
|
||||
Location: createLocation,
|
||||
}
|
||||
|
||||
export const cleanDatabase = async (options = {}) => {
|
||||
|
||||
24
backend/src/seed/factories/locations.js
Normal file
24
backend/src/seed/factories/locations.js
Normal file
@ -0,0 +1,24 @@
|
||||
export default function create() {
|
||||
return {
|
||||
factory: async ({ args, neodeInstance }) => {
|
||||
const defaults = {
|
||||
name: 'Germany',
|
||||
namePT: 'Alemanha',
|
||||
nameDE: 'Deutschland',
|
||||
nameES: 'Alemania',
|
||||
nameNL: 'Duitsland',
|
||||
namePL: 'Niemcy',
|
||||
nameFR: 'Allemagne',
|
||||
nameIT: 'Germania',
|
||||
nameEN: 'Germany',
|
||||
id: 'country.10743216036480410',
|
||||
type: 'country',
|
||||
}
|
||||
args = {
|
||||
...defaults,
|
||||
...args,
|
||||
}
|
||||
return neodeInstance.create('Location', args)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -25,6 +25,86 @@ import { gql } from '../jest/helpers'
|
||||
const { mutate } = createTestClient(server)
|
||||
|
||||
const f = Factory()
|
||||
|
||||
const [Hamburg, Berlin, Germany, Paris, France] = await Promise.all([
|
||||
f.create('Location', {
|
||||
id: 'region.5127278006398860',
|
||||
name: 'Hamburg',
|
||||
type: 'region',
|
||||
lat: 10.0,
|
||||
lng: 53.55,
|
||||
nameES: 'Hamburgo',
|
||||
nameFR: 'Hambourg',
|
||||
nameIT: 'Amburgo',
|
||||
nameEN: 'Hamburg',
|
||||
namePT: 'Hamburgo',
|
||||
nameDE: 'Hamburg',
|
||||
nameNL: 'Hamburg',
|
||||
namePL: 'Hamburg',
|
||||
}),
|
||||
f.create('Location', {
|
||||
id: 'region.14880313158564380',
|
||||
type: 'region',
|
||||
name: 'Berlin',
|
||||
lat: 13.38333,
|
||||
lng: 52.51667,
|
||||
nameES: 'Berlín',
|
||||
nameFR: 'Berlin',
|
||||
nameIT: 'Berlino',
|
||||
nameEN: 'Berlin',
|
||||
namePT: 'Berlim',
|
||||
nameDE: 'Berlin',
|
||||
nameNL: 'Berlijn',
|
||||
namePL: 'Berlin',
|
||||
}),
|
||||
f.create('Location', {
|
||||
id: 'country.10743216036480410',
|
||||
name: 'Germany',
|
||||
type: 'country',
|
||||
namePT: 'Alemanha',
|
||||
nameDE: 'Deutschland',
|
||||
nameES: 'Alemania',
|
||||
nameNL: 'Duitsland',
|
||||
namePL: 'Niemcy',
|
||||
nameFR: 'Allemagne',
|
||||
nameIT: 'Germania',
|
||||
nameEN: 'Germany',
|
||||
}),
|
||||
f.create('Location', {
|
||||
id: 'region.9397217726497330',
|
||||
name: 'Paris',
|
||||
type: 'region',
|
||||
lat: 2.35183,
|
||||
lng: 48.85658,
|
||||
nameES: 'París',
|
||||
nameFR: 'Paris',
|
||||
nameIT: 'Parigi',
|
||||
nameEN: 'Paris',
|
||||
namePT: 'Paris',
|
||||
nameDE: 'Paris',
|
||||
nameNL: 'Parijs',
|
||||
namePL: 'Paryż',
|
||||
}),
|
||||
f.create('Location', {
|
||||
id: 'country.9759535382641660',
|
||||
name: 'France',
|
||||
type: 'country',
|
||||
namePT: 'França',
|
||||
nameDE: 'Frankreich',
|
||||
nameES: 'Francia',
|
||||
nameNL: 'Frankrijk',
|
||||
namePL: 'Francja',
|
||||
nameFR: 'France',
|
||||
nameIT: 'Francia',
|
||||
nameEN: 'France',
|
||||
}),
|
||||
])
|
||||
await Promise.all([
|
||||
Berlin.relateTo(Germany, 'isIn'),
|
||||
Hamburg.relateTo(Germany, 'isIn'),
|
||||
Paris.relateTo(France, 'isIn'),
|
||||
])
|
||||
|
||||
const [racoon, rabbit, wolf, bear, turtle, rhino] = await Promise.all([
|
||||
f.create('Badge', {
|
||||
id: 'indiegogo_en_racoon',
|
||||
@ -112,6 +192,13 @@ import { gql } from '../jest/helpers'
|
||||
}),
|
||||
])
|
||||
|
||||
await Promise.all([
|
||||
peterLustig.relateTo(Berlin, 'isIn'),
|
||||
bobDerBaumeister.relateTo(Hamburg, 'isIn'),
|
||||
jennyRostock.relateTo(Paris, 'isIn'),
|
||||
huey.relateTo(Paris, 'isIn'),
|
||||
])
|
||||
|
||||
await Promise.all([
|
||||
peterLustig.relateTo(racoon, 'rewarded'),
|
||||
peterLustig.relateTo(rhino, 'rewarded'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user