Skip to content

Commit

Permalink
[CodeFactor] Apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
code-factor committed Mar 23, 2023
1 parent be5aa73 commit a9057f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 10 additions & 10 deletions hapi/src/services/producer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const updateProducers = async (producers = []) => {
let topProducers = producers.slice(0, eosConfig.eosTopLimit)

topProducers = topProducers.filter(
producer =>
(producer) =>
producer?.health_status && Object.keys(producer.health_status).length > 0
)
await nodeService.clearNodes()
Expand All @@ -53,7 +53,7 @@ const updateProducers = async (producers = []) => {
const insertedRows = await hasuraUtil.request(upsertMutation, { producers })

await hasuraUtil.request(clearMutation, {
owners: producers.map(producer => producer.owner)
owners: producers.map((producer) => producer.owner)
})

return insertedRows.insert_producer.returning
Expand Down Expand Up @@ -96,11 +96,11 @@ const getProducersSummary = async () => {
return rows
}

const syncNodes = async producers => {
const syncNodes = async (producers) => {
if (!producers?.length) return

let nodes = producers.flatMap(producer => {
return (producer.bp_json?.nodes || []).map(node => {
let nodes = producers.flatMap((producer) => {
return (producer.bp_json?.nodes || []).map((node) => {
node.producer_id = producer.id

return nodeService.getFormatNode(node)
Expand Down Expand Up @@ -140,9 +140,9 @@ const syncEndpoints = async () => {

if (!count) return

let endpoints = await Promise.all(
producers.map(async producer => {
const endpoints = producer.nodes.flatMap(node => node?.endpoints || [])
const endpoints = await Promise.all(
producers.map(async (producer) => {
const endpoints = producer.nodes.flatMap((node) => node?.endpoints || [])

return await endpointsHealth(endpoints, producer.id)
})
Expand All @@ -157,7 +157,7 @@ const endpointsHealth = async (endpoints, producer_id) => {
for (index in endpoints) {
const endpoint = { ...endpoints[index] }
const repeatedIndex = checkedList.findIndex(
info => info.value === endpoint.value
(info) => info.value === endpoint.value
)
const isRepeated = repeatedIndex >= 0

Expand Down Expand Up @@ -224,7 +224,7 @@ const requestProducers = async ({ where, whereEndpointList }) => {
return !producers ? {} : { producers, total: aggregate.count }
}

const getProducersInfo = async bpParams => {
const getProducersInfo = async (bpParams) => {
const whereCondition = {
where: {
_and: [{ bp_json: { _neq: {} } }, { owner: { _in: bpParams?.owners } }]
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/gql/producer.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,3 @@ export const HISTORY_ENDPOINTS_BY_PRODUCER_QUERY = gql`query($id: Int){
date
}
}`


0 comments on commit a9057f1

Please sign in to comment.