mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Follow @Tirokk's suggestion and rename key=>id
This commit is contained in:
parent
b6dcafcc2b
commit
99740e6ad6
@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
key: { type: 'string', primary: true, lowercase: true },
|
||||
id: { type: 'string', primary: true, lowercase: true },
|
||||
status: { type: 'string', valid: ['permanent', 'temporary'] },
|
||||
type: { type: 'string', valid: ['role', 'crowdfunding'] },
|
||||
icon: { type: 'string', required: true },
|
||||
|
||||
@ -5,9 +5,9 @@ const instance = neode()
|
||||
|
||||
const getUserAndBadge = async ({ badgeKey, userId }) => {
|
||||
let user = await instance.first('User', 'id', userId)
|
||||
const badge = await instance.first('Badge', 'key', badgeKey)
|
||||
const badge = await instance.first('Badge', 'id', badgeKey)
|
||||
if (!user) throw new UserInputError("Couldn't find a user with that id")
|
||||
if (!badge) throw new UserInputError("Couldn't find a badge with that key")
|
||||
if (!badge) throw new UserInputError("Couldn't find a badge with that id")
|
||||
return { user, badge }
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ export default {
|
||||
// silly neode cannot remove relationships
|
||||
await session.run(
|
||||
`
|
||||
MATCH (badge:Badge {key: $badgeKey})-[reward:REWARDED]->(rewardedUser:User {id: $userId})
|
||||
MATCH (badge:Badge {id: $badgeKey})-[reward:REWARDED]->(rewardedUser:User {id: $userId})
|
||||
DELETE reward
|
||||
RETURN rewardedUser
|
||||
`,
|
||||
|
||||
@ -31,7 +31,7 @@ describe('rewards', () => {
|
||||
email: 'admin@example.org',
|
||||
})
|
||||
badge = await factory.create('Badge', {
|
||||
key: 'indiegogo_en_rhino',
|
||||
id: 'indiegogo_en_rhino',
|
||||
type: 'crowdfunding',
|
||||
status: 'permanent',
|
||||
icon: '/img/badges/indiegogo_en_rhino.svg',
|
||||
@ -48,7 +48,7 @@ describe('rewards', () => {
|
||||
reward(badgeKey: $from, userId: $to) {
|
||||
id
|
||||
badges {
|
||||
key
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,14 +70,14 @@ describe('rewards', () => {
|
||||
client = new GraphQLClient(host, { headers })
|
||||
})
|
||||
|
||||
describe('badge for key does not exist', () => {
|
||||
describe('badge for id does not exist', () => {
|
||||
it('rejects with a telling error message', async () => {
|
||||
await expect(
|
||||
client.request(mutation, {
|
||||
...variables,
|
||||
from: 'bullshit',
|
||||
}),
|
||||
).rejects.toThrow("Couldn't find a badge with that key")
|
||||
).rejects.toThrow("Couldn't find a badge with that id")
|
||||
})
|
||||
})
|
||||
|
||||
@ -96,7 +96,7 @@ describe('rewards', () => {
|
||||
const expected = {
|
||||
reward: {
|
||||
id: 'u1',
|
||||
badges: [{ key: 'indiegogo_en_rhino' }],
|
||||
badges: [{ id: 'indiegogo_en_rhino' }],
|
||||
},
|
||||
}
|
||||
await expect(client.request(mutation, variables)).resolves.toEqual(expected)
|
||||
@ -104,13 +104,13 @@ describe('rewards', () => {
|
||||
|
||||
it('rewards a second different badge to same user', async () => {
|
||||
await factory.create('Badge', {
|
||||
key: 'indiegogo_en_racoon',
|
||||
id: 'indiegogo_en_racoon',
|
||||
icon: '/img/badges/indiegogo_en_racoon.svg',
|
||||
})
|
||||
const expected = {
|
||||
reward: {
|
||||
id: 'u1',
|
||||
badges: [{ key: 'indiegogo_en_racoon' }, { key: 'indiegogo_en_rhino' }],
|
||||
badges: [{ id: 'indiegogo_en_racoon' }, { id: 'indiegogo_en_rhino' }],
|
||||
},
|
||||
}
|
||||
await client.request(mutation, variables)
|
||||
@ -126,7 +126,7 @@ describe('rewards', () => {
|
||||
const expected = {
|
||||
reward: {
|
||||
id: 'u2',
|
||||
badges: [{ key: 'indiegogo_en_rhino' }],
|
||||
badges: [{ id: 'indiegogo_en_rhino' }],
|
||||
},
|
||||
}
|
||||
await expect(
|
||||
@ -146,12 +146,12 @@ describe('rewards', () => {
|
||||
User(id: "u1") {
|
||||
badgesCount
|
||||
badges {
|
||||
key
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const expected = { User: [{ badgesCount: 1, badges: [{ key: 'indiegogo_en_rhino' }] }] }
|
||||
const expected = { User: [{ badgesCount: 1, badges: [{ id: 'indiegogo_en_rhino' }] }] }
|
||||
|
||||
await expect(client.request(query)).resolves.toEqual(expected)
|
||||
})
|
||||
@ -183,7 +183,7 @@ describe('rewards', () => {
|
||||
unreward(badgeKey: $from, userId: $to) {
|
||||
id
|
||||
badges {
|
||||
key
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,12 +196,12 @@ describe('rewards', () => {
|
||||
User(id: "u1") {
|
||||
badgesCount
|
||||
badges {
|
||||
key
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
const expected = { User: [{ badgesCount: 1, badges: [{ key: 'indiegogo_en_rhino' }] }] }
|
||||
const expected = { User: [{ badgesCount: 1, badges: [{ id: 'indiegogo_en_rhino' }] }] }
|
||||
const client = new GraphQLClient(host)
|
||||
await expect(client.request(query)).resolves.toEqual(expected)
|
||||
})
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
type Badge {
|
||||
key: ID!
|
||||
id: ID!
|
||||
type: BadgeType!
|
||||
status: BadgeStatus!
|
||||
icon: String!
|
||||
|
||||
@ -7,27 +7,27 @@ import Factory from './factories'
|
||||
const f = Factory()
|
||||
const [racoon, rabbit, wolf, bear, turtle, rhino] = await Promise.all([
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_racoon',
|
||||
id: 'indiegogo_en_racoon',
|
||||
icon: '/img/badges/indiegogo_en_racoon.svg',
|
||||
}),
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_rabbit',
|
||||
id: 'indiegogo_en_rabbit',
|
||||
icon: '/img/badges/indiegogo_en_rabbit.svg',
|
||||
}),
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_wolf',
|
||||
id: 'indiegogo_en_wolf',
|
||||
icon: '/img/badges/indiegogo_en_wolf.svg',
|
||||
}),
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_bear',
|
||||
id: 'indiegogo_en_bear',
|
||||
icon: '/img/badges/indiegogo_en_bear.svg',
|
||||
}),
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_turtle',
|
||||
id: 'indiegogo_en_turtle',
|
||||
icon: '/img/badges/indiegogo_en_turtle.svg',
|
||||
}),
|
||||
f.create('Badge', {
|
||||
key: 'indiegogo_en_rhino',
|
||||
id: 'indiegogo_en_rhino',
|
||||
icon: '/img/badges/indiegogo_en_rhino.svg',
|
||||
}),
|
||||
])
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
[?] type: String, // in nitro this is a defined enum - seems good for now
|
||||
[X] required: true
|
||||
},
|
||||
[X] key: {
|
||||
[X] id: {
|
||||
[X] type: String,
|
||||
[X] required: true
|
||||
},
|
||||
@ -43,7 +43,7 @@
|
||||
CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as badge
|
||||
MERGE(b:Badge {id: badge._id["$oid"]})
|
||||
ON CREATE SET
|
||||
b.key = badge.key,
|
||||
b.id = badge.key,
|
||||
b.type = badge.type,
|
||||
b.icon = replace(badge.image.path, 'https://api-alpha.human-connection.org', ''),
|
||||
b.status = badge.status,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div :class="[badges.length === 2 && 'hc-badges-dual']" class="hc-badges">
|
||||
<div v-for="badge in badges" :key="badge.key" class="hc-badge-container">
|
||||
<div v-for="badge in badges" :key="badge.id" class="hc-badge-container">
|
||||
<img :title="badge.key" :src="badge.icon | proxyApiUrl" class="hc-badge" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -24,7 +24,7 @@ export default app => {
|
||||
name: name${lang}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ export default i18n => {
|
||||
name: name${lang}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ export default i18n => {
|
||||
name: name${lang}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ export default i18n => {
|
||||
name: name${lang}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ export default i18n => {
|
||||
}
|
||||
createdAt
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
badgesCount
|
||||
@ -37,7 +37,7 @@ export default i18n => {
|
||||
contributionsCount
|
||||
commentsCount
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
location {
|
||||
@ -58,7 +58,7 @@ export default i18n => {
|
||||
contributionsCount
|
||||
commentsCount
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
location {
|
||||
|
||||
@ -156,7 +156,7 @@ export default {
|
||||
name: name${this.$i18n.locale().toUpperCase()}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ export default {
|
||||
name: name${this.$i18n.locale().toUpperCase()}
|
||||
}
|
||||
badges {
|
||||
key
|
||||
id
|
||||
icon
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user