Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Sep 3, 2021
2 parents 937370e + 7576bfd commit 8480562
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 70 deletions.
4 changes: 2 additions & 2 deletions hapi/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const init = async () => {
if (!input) throw new Error('Invalid ratebp Input')

const {
ratingInput: { user, producer }
ratingInput: { user, producer, transacction }
} = input
const isValidAccountName = accountValidation([
{ name: user, type: 'user account' },
Expand All @@ -44,7 +44,7 @@ const init = async () => {
throw new Error(isValidAccountName.message)

const resultEden = await updateBpStats(producer)
const result = await updateUserRatings(user, producer)
const result = await updateUserRatings(user, producer, transacction)

return { resultEden: resultEden, ...result }
} catch (error) {
Expand Down
8 changes: 5 additions & 3 deletions hapi/src/libs/sync-user-rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getUserRatings = async () => {
}

// updates the postgresdb
const updateUserRatings = async (userAccount, bpAccount) => {
const updateUserRatings = async (userAccount, bpAccount, transaction) => {
console.log('==== Updating user ratings ====')

try {
Expand All @@ -51,15 +51,17 @@ const updateUserRatings = async (userAccount, bpAccount) => {
uniq_rating: blockProducer.uniq_rating,
user: blockProducer.user,
bp: blockProducer.bp,
ratings: ratings
ratings: ratings,
tx_data: transaction
})

if (!result) {
const insertResult = await (await massiveDB).user_ratings.insert({
uniq_rating: blockProducer.uniq_rating,
user: blockProducer.user,
bp: blockProducer.bp,
ratings
ratings,
tx_data: transaction
})

if (!insertResult)
Expand Down
1 change: 1 addition & 0 deletions hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Mutation {
input RatingInput {
user: String!
producer: String!
transacction: jsonb!
}

type RatingOutput {
Expand Down
12 changes: 11 additions & 1 deletion webapp/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,17 @@
"core_liquid_balance": "Liquid Balance",
"inactive": "Inactive",
"logout": "Logout",
"title": "Profile for account"
"title": "Profile for account",
"yourRating": "Your Rating",
"unpublish": "REMOVE RATING",
"youRated": "You rated",
"infrastructure": "Infrastructure",
"transparency": "Transparency",
"trustiness": "Trustiness",
"community": "Community",
"development": "Development",
"voteWithoutLogin": "You need to login to execute this action",
"success" : "Success!"
},

"bpRatePage": {
Expand Down
14 changes: 12 additions & 2 deletions webapp/src/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,17 @@
"core_liquid_balance": "Balance Líquido",
"inactive": "Inactiva",
"logout": "Cerrar Sesión",
"title": "Perfil para cuenta"
"title": "Perfil para cuenta",
"yourRating": "Su calificación",
"unpublish": "ANULAR CALIFICACIÓN",
"youRated": "Tu calificaste",
"infrastructure": "Infraestructura",
"transparency": "Transparencia",
"trustiness": "Lealtad",
"community": "Comunidad",
"development": "Desarrollo",
"voteWithoutLogin": "Necesitas iniciar sesión para ejecutar esta acción",
"success" : "¡Éxito!"
},

"bpRatePage": {
Expand Down Expand Up @@ -215,7 +225,7 @@
"voteWithoutLogin": "Necesita iniciar sesión para votar por un proxy",
"totalVotes": "Total de votos",
"labelTool": "vota por",
"success" : "Éxito!",
"success" : "¡Éxito!",
"title": "Calificaciones de productor de bloques EOS",
"proxyProfile": "Reseñas sobre EOS proxy"
},
Expand Down
13 changes: 12 additions & 1 deletion webapp/src/models/BlockProducer/blockProducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const initialState = {
producer: null,
userRate: null,
edenRate: null,
transacction: null,
showSortSelected: false
}

Expand Down Expand Up @@ -108,6 +109,9 @@ const Proxies = {
},
addEdenRate(state, edenRate) {
return { ...state, edenRate }
},
addTransacction(state, transacction) {
return { ...state, transacction }
}
},
effects: (dispatch) => ({
Expand All @@ -122,6 +126,9 @@ const Proxies = {
filters
)
},
async saveLastTransaction(transacction) {
this.addTransacction(transacction)
},
async getBlockProducerByOwner(owner, state) {
try {
dispatch.isLoading.storeIsContentLoading(true)
Expand Down Expand Up @@ -215,7 +222,11 @@ const Proxies = {
data: { rateProducer }
} = await apolloClient.mutate({
variables: {
ratingInput: { producer: bp, user }
ratingInput: {
producer: bp,
user,
transacction: state.blockProducers.transacction
}
},
mutation: MUTATION_UPDATE_RATING
})
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/models/User/query_get_rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import gql from 'graphql-tag'

const QUERY_RATING = gql`
query getRates($user: String) {
user_ratings(where: { user: { _eq: $user } }) {
user_ratings(where: { user: { _eq: $user } }, order_by: { tx_data: asc }) {
bp
ratings
uniq_rating
user
tx_data
}
}
`
Expand Down
Loading

0 comments on commit 8480562

Please sign in to comment.