-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(jungle): migrate dev environment to jungle 4 (#988) * fix(jungle): migrate dev environment to jungle 4 * fix(jungle): migrate dev environment to jungle 4 * Improve(hapi): changed hapi server routes structure (#992) * fix(enviroment): change env value * fix(hasura): add permissions tables * fix(comments): fix comments section * fix(hyperion): fix codefactor issues * fix(hyperion): fix codefactor issues * fix(hasura): delete migration restriction * fix(hyperion): fix updater flows * improve(hapi): changed hapi server routes structure * feat(hapi): created eosrate stats api endpoint (#993) * fix(enviroment): change env value * fix(hasura): add permissions tables * fix(comments): fix comments section * fix(hyperion): fix codefactor issues * fix(hyperion): fix codefactor issues * fix(hasura): delete migration restriction * fix(hyperion): fix updater flows * feat(hapi): created eosrate stats api endpoint * fix(hapi): fix codefactor error * fix(webapp): added validation on bp profile page (#995) * fix(enviroment): change env value * fix(hasura): add permissions tables * fix(comments): fix comments section * fix(hyperion): fix codefactor issues * fix(hyperion): fix codefactor issues * fix(hasura): delete migration restriction * fix(hyperion): fix updater flows * feat(hapi): created eosrate stats api endpoint * fix(hapi): fix codefactor error * fix(webapp): added validation on bp profile page Co-authored-by: Angelo Castro Gamboa <51149817+AngeloCG97@users.noreply.github.com>
- Loading branch information
1 parent
9f59bc4
commit 766cbba
Showing
38 changed files
with
916 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const Boom = require('@hapi/boom') | ||
const Joi = require('joi') | ||
|
||
const { ratesStatsService } = require('../services') | ||
|
||
module.exports = { | ||
method: 'POST', | ||
path: '/get-rates-stats', | ||
handler: async ({ payload: { input } }) => { | ||
try { | ||
if (!input) throw new Error('Invalid get-rates-stats Input') | ||
|
||
const whereCondition = input?.ratesStatsInput?.bps | ||
? { _in: input?.ratesStatsInput?.bps } | ||
: { _nin: [] } | ||
const bpsStats = await ratesStatsService.getRatesStats({ | ||
where: { bp: whereCondition } | ||
}) | ||
|
||
return { bpsStats } | ||
} catch (error) { | ||
console.error('get-rates-stats', error) | ||
|
||
return Boom.badRequest(error.message) | ||
} | ||
}, | ||
options: { | ||
validate: { | ||
payload: Joi.object({ | ||
input: Joi.object({ | ||
ratesStatsInput: Joi.object({ | ||
bps: Joi.array().items(Joi.string().required()).optional() | ||
}).required() | ||
}).required() | ||
}).options({ stripUnknown: true }) | ||
}, | ||
auth: 'simple' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
method: 'GET', | ||
path: '/healthz', | ||
handler: () => { | ||
return '<h2>EOS Rate HTTP API service</h2>' | ||
}, | ||
options: { | ||
auth: false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const healthzRoute = require('./healthz.route') | ||
const ratebpRoute = require('./ratebp.route') | ||
const getRatesStats = require('./get-rates-stats.route') | ||
|
||
module.exports = [healthzRoute, ratebpRoute, getRatesStats] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const Boom = require('@hapi/boom') | ||
const Joi = require('joi') | ||
|
||
const { | ||
updateBpStatsUtil, | ||
updateUserRatingUtil, | ||
validateAccountNameUtil | ||
} = require('../utils') | ||
|
||
module.exports = { | ||
method: 'POST', | ||
path: '/ratebp', | ||
handler: async ({ payload: { input } }) => { | ||
try { | ||
if (!input) throw new Error('Invalid ratebp Input') | ||
|
||
const { | ||
ratingInput: { user, producer, transaction, isEden } | ||
} = input | ||
const isValidAccountName = validateAccountNameUtil([ | ||
{ name: user, type: 'user account' }, | ||
{ name: producer, type: 'block producer' } | ||
]) | ||
|
||
if (!isValidAccountName.isValidAccountName) | ||
throw new Error(isValidAccountName.message) | ||
|
||
const { edenResult, totalStats } = await updateBpStatsUtil(producer) | ||
const result = await updateUserRatingUtil( | ||
user, | ||
producer, | ||
transaction, | ||
isEden | ||
) | ||
|
||
return { resultEden: edenResult, totalStats, ...result } | ||
} catch (error) { | ||
console.error('ratebp', error) | ||
|
||
return Boom.badRequest(error.message) | ||
} | ||
}, | ||
options: { | ||
validate: { | ||
payload: Joi.object({ | ||
input: Joi.object({ | ||
ratingInput: Joi.object({ | ||
user: Joi.string().required(), | ||
isEden: Joi.boolean().required(), | ||
producer: Joi.string().required(), | ||
transaction: Joi.object().required() | ||
}).required() | ||
}).required() | ||
}).options({ stripUnknown: true }) | ||
}, | ||
auth: false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { hasuraUtil } = require('../utils') | ||
|
||
const getRatesStats = async ({ where }) => { | ||
const query = ` | ||
query ($where: total_ratings_stats_bool_exp!) { | ||
total_ratings_stats(where: $where) { | ||
average | ||
bp | ||
community | ||
development | ||
infrastructure | ||
ratings_cntr | ||
transparency | ||
trustiness | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(query, { where }) | ||
|
||
return data?.total_ratings_stats || [{}] | ||
} | ||
|
||
module.exports = { | ||
getRatesStats | ||
} |
Oops, something went wrong.