From 8550d1433291d839e0743651b5ed385bce29bb47 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Tue, 7 Mar 2023 17:11:13 -0600 Subject: [PATCH 01/20] feat(hapi): avoid requesting duplicate endpoints --- hapi/src/services/node.service.js | 10 +++---- hapi/src/services/producer.service.js | 38 +++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/hapi/src/services/node.service.js b/hapi/src/services/node.service.js index 7f0e525c..ac558fc4 100644 --- a/hapi/src/services/node.service.js +++ b/hapi/src/services/node.service.js @@ -52,15 +52,11 @@ const updateEndpointInfo = async endpoint => { } ` - const { nodeInfo, ...response } = await producerUtil.getNodeInfo( - endpoint.value - ) - await hasuraUtil.request(updateMutation, { id: endpoint.id, - response, - head_block_time: nodeInfo?.head_block_time || null, - updated_at: new Date() + response: endpoint?.response || {}, + head_block_time: endpoint?.head_block_time || null, + updated_at: endpoint.updated_at }) } diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index 2fc1458d..c2e7d6bf 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -1,4 +1,4 @@ -const { hasuraUtil, sequelizeUtil } = require('../utils') +const { hasuraUtil, sequelizeUtil, producerUtil } = require('../utils') const { eosConfig } = require('../config') const lacchainService = require('./lacchain.service') @@ -71,7 +71,6 @@ const syncProducers = async () => { if (producers?.length) { producers = await updateProducers(producers) await syncNodes(producers.slice(0, eosConfig.eosTopLimit)) - await syncEndpoints() if (!eosConfig.stateHistoryPluginEndpoint) { await statsService.sync() @@ -112,7 +111,7 @@ const syncNodes = async producers => { const syncEndpoints = async () => { const query = ` query { - endpoints: endpoint (where: {type: {_in: ["api","ssl"]}}) { + endpoints: endpoint (where: {type: {_in: ["api","ssl"]}}, order_by: {value: asc}) { id, type, value @@ -123,9 +122,38 @@ const syncEndpoints = async () => { if (!endpoints?.length) return - endpoints.forEach(async endpoint => { + const checkedList = [] + const today = new Date() + + today.setHours(0,0,0,0) + + for(index in endpoints){ + const endpoint = {...endpoints[index]} + const previous = checkedList[checkedList.length - 1] + let startTime + + if(previous?.value === endpoint.value){ + endpoint.response = previous.response + endpoint.head_block_time = previous.head_block_time + endpoint.updated_at = previous.updated_at + }else{ + startTime = new Date() + const {nodeInfo, ...reponse} = await producerUtil.getNodeInfo( + endpoint.value + ) + endpoint.time = (new Date() - startTime) / 1000 + + endpoint.response = reponse + endpoint.head_block_time = nodeInfo?.head_block_time || null + endpoint.updated_at = new Date() + } + await nodeService.updateEndpointInfo(endpoint) - }) + + if(previous?.value !== endpoint.value){ + checkedList.push(endpoint) + } + } } const requestProducers = async ({ where, whereEndpointList }) => { From 4e82091a84a5ec5ea396de6a47fd17338bfc0413 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Tue, 7 Mar 2023 17:11:49 -0600 Subject: [PATCH 02/20] chore(webapp): use endpoint updated time instead of local time --- webapp/src/components/EndpointsTable/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/EndpointsTable/index.js b/webapp/src/components/EndpointsTable/index.js index 0b9c115d..9e246985 100644 --- a/webapp/src/components/EndpointsTable/index.js +++ b/webapp/src/components/EndpointsTable/index.js @@ -42,7 +42,7 @@ const EndpointsTable = ({ producers }) => { const getStatus = (endpoint) => { if (endpoint.response.status === undefined) return - const diffBlockTimems = new Date() - new Date(endpoint.head_block_time) + const diffBlockTimems = new Date(endpoint.updated_at) - new Date(endpoint.head_block_time) if (diffBlockTimems <= syncToleranceInterval) { return 'greenLight' From 9bc804f198833c52c82a3065ef5aecea18e74177 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 8 Mar 2023 12:10:32 -0600 Subject: [PATCH 03/20] perf(hapi): improve endpoints health check --- hapi/src/services/producer.service.js | 64 ++++++++++++++++++++------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index c2e7d6bf..935803fa 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -110,50 +110,82 @@ const syncNodes = async producers => { const syncEndpoints = async () => { const query = ` - query { - endpoints: endpoint (where: {type: {_in: ["api","ssl"]}}, order_by: {value: asc}) { - id, - type, - value + { + endpoint_aggregate(where: {type: {_in: ["api", "ssl"]}}) { + aggregate { + count + } + } + producers : producer(where: {nodes: {endpoints: {_and: [{value: {_gt: ""}}]}}}, order_by: {rank: asc}) { + id + nodes { + endpoints(where: {type: {_in: ["api", "ssl"]}}, order_by: {value: asc}) { + id + value + type + } + } } } ` - const { endpoints } = await hasuraUtil.request(query) + const { + producers, + endpoint_aggregate: { + aggregate: { count } + } + } = await hasuraUtil.request(query) - if (!endpoints?.length) return + if (!count) return - const checkedList = [] const today = new Date() today.setHours(0,0,0,0) + let endpoints = await Promise.all( + producers.map(async producer => { + const endpoints = producer.nodes.flatMap(node => node?.endpoints || []) + + return await endpointsHealth(endpoints) + })) + + endpoints = endpoints.flat() +} + +const endpointsHealth = async endpoints => { + const checkedList = [] + for(index in endpoints){ const endpoint = {...endpoints[index]} - const previous = checkedList[checkedList.length - 1] - let startTime + const repeatedIndex = checkedList.findIndex(info => info.value === endpoint.value) + const isRepeated = repeatedIndex >= 0 - if(previous?.value === endpoint.value){ + if(isRepeated){ + const previous = checkedList[repeatedIndex] + endpoint.response = previous.response endpoint.head_block_time = previous.head_block_time endpoint.updated_at = previous.updated_at }else{ - startTime = new Date() - const {nodeInfo, ...reponse} = await producerUtil.getNodeInfo( + + const startTime = new Date() + const {nodeInfo, ...response} = await producerUtil.getNodeInfo( endpoint.value ) - endpoint.time = (new Date() - startTime) / 1000 - endpoint.response = reponse + endpoint.time = (new Date() - startTime) / 1000 + endpoint.response = response endpoint.head_block_time = nodeInfo?.head_block_time || null endpoint.updated_at = new Date() } await nodeService.updateEndpointInfo(endpoint) - if(previous?.value !== endpoint.value){ + if(!isRepeated){ checkedList.push(endpoint) } } + + return checkedList } const requestProducers = async ({ where, whereEndpointList }) => { From 000430cf2a16f5debbb2b68d75d22e350f3506a0 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 8 Mar 2023 15:12:30 -0600 Subject: [PATCH 04/20] feat(hasura): add health_check_history table --- hasura/metadata/backend_configs.yaml | 1 + .../tables/public_health_check_history.yaml | 3 +++ .../databases/default/tables/tables.yaml | 1 + hasura/metadata/metrics_config.yaml | 1 + hasura/metadata/opentelemetry.yaml | 1 + .../down.sql | 1 + .../up.sql | 18 ++++++++++++++++++ 7 files changed, 26 insertions(+) create mode 100644 hasura/metadata/backend_configs.yaml create mode 100644 hasura/metadata/databases/default/tables/public_health_check_history.yaml create mode 100644 hasura/metadata/metrics_config.yaml create mode 100644 hasura/metadata/opentelemetry.yaml create mode 100644 hasura/migrations/default/1678309776436_create_table_public_health_check_history/down.sql create mode 100644 hasura/migrations/default/1678309776436_create_table_public_health_check_history/up.sql diff --git a/hasura/metadata/backend_configs.yaml b/hasura/metadata/backend_configs.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/hasura/metadata/backend_configs.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/databases/default/tables/public_health_check_history.yaml b/hasura/metadata/databases/default/tables/public_health_check_history.yaml new file mode 100644 index 00000000..09677074 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_health_check_history.yaml @@ -0,0 +1,3 @@ +table: + name: health_check_history + schema: public diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 4cbfb5c3..951bdcae 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -4,6 +4,7 @@ - "!include public_demux_state.yaml" - "!include public_endpoint.yaml" - "!include public_endpoints_by_producer_id.yaml" +- "!include public_health_check_history.yaml" - "!include public_node.yaml" - "!include public_node_info.yaml" - "!include public_producer.yaml" diff --git a/hasura/metadata/metrics_config.yaml b/hasura/metadata/metrics_config.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/hasura/metadata/metrics_config.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/opentelemetry.yaml b/hasura/metadata/opentelemetry.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/hasura/metadata/opentelemetry.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/migrations/default/1678309776436_create_table_public_health_check_history/down.sql b/hasura/migrations/default/1678309776436_create_table_public_health_check_history/down.sql new file mode 100644 index 00000000..42d2d83c --- /dev/null +++ b/hasura/migrations/default/1678309776436_create_table_public_health_check_history/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."health_check_history"; diff --git a/hasura/migrations/default/1678309776436_create_table_public_health_check_history/up.sql b/hasura/migrations/default/1678309776436_create_table_public_health_check_history/up.sql new file mode 100644 index 00000000..c8f8700b --- /dev/null +++ b/hasura/migrations/default/1678309776436_create_table_public_health_check_history/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."health_check_history" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "date" date NOT NULL, "total_checks" integer NOT NULL DEFAULT 1, "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("id") , UNIQUE ("id"), UNIQUE ("date")); +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_health_check_history_updated_at" +BEFORE UPDATE ON "public"."health_check_history" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_health_check_history_updated_at" ON "public"."health_check_history" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; From 5771ae51fcad7cfe28a3db10444c17f5a1843278 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Fri, 10 Mar 2023 15:44:08 -0600 Subject: [PATCH 05/20] feat(hasura): add endpoints check history table --- .../default/tables/public_endpoints_check_history.yaml | 3 +++ hasura/metadata/databases/default/tables/tables.yaml | 1 + .../down.sql | 1 + .../up.sql | 2 ++ 4 files changed, 7 insertions(+) create mode 100644 hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml create mode 100644 hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/down.sql create mode 100644 hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/up.sql diff --git a/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml b/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml new file mode 100644 index 00000000..b1badbbe --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml @@ -0,0 +1,3 @@ +table: + name: endpoints_check_history + schema: public diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 951bdcae..6b432c6b 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -4,6 +4,7 @@ - "!include public_demux_state.yaml" - "!include public_endpoint.yaml" - "!include public_endpoints_by_producer_id.yaml" +- "!include public_endpoints_check_history.yaml" - "!include public_health_check_history.yaml" - "!include public_node.yaml" - "!include public_node_info.yaml" diff --git a/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/down.sql b/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/down.sql new file mode 100644 index 00000000..828abe03 --- /dev/null +++ b/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."endpoints_check_history"; diff --git a/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/up.sql b/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/up.sql new file mode 100644 index 00000000..fd401ef9 --- /dev/null +++ b/hasura/migrations/default/1678393517233_create_table_public_endpoints_check_history/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."endpoints_check_history" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "successful_checks" integer NOT NULL, "sum_total_time" integer NOT NULL, "value" varchar NOT NULL, "date" date NOT NULL, "producer_id" integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("producer_id") REFERENCES "public"."producer"("id") ON UPDATE restrict ON DELETE cascade, UNIQUE ("id")); +CREATE EXTENSION IF NOT EXISTS pgcrypto; From e90c089abef5a86ac3937b48a236a08cd3c7c9db Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Fri, 10 Mar 2023 15:46:37 -0600 Subject: [PATCH 06/20] feat(hapi): add service to manage health check history --- .../services/health-check-history.service.js | 113 ++++++++++++++++++ hapi/src/services/index.js | 2 + hapi/src/services/producer.service.js | 17 +-- 3 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 hapi/src/services/health-check-history.service.js diff --git a/hapi/src/services/health-check-history.service.js b/hapi/src/services/health-check-history.service.js new file mode 100644 index 00000000..be393e07 --- /dev/null +++ b/hapi/src/services/health-check-history.service.js @@ -0,0 +1,113 @@ +const { hasuraUtil } = require('../utils') + +const newEndpointsHealthHistory = async (endpoints, payload) => { + const mutation = ` + mutation insert($payload: health_check_history_insert_input!,$endpoints: [endpoints_check_history_insert_input!]!) { + insert_health_check_history_one(object: $payload, on_conflict: {constraint: health_check_history_pkey, update_columns: [total_checks, date]}) { + id + } + insert_endpoints_check_history(objects: $endpoints, on_conflict: {constraint: endpoints_check_history_pkey, update_columns: [producer_id, value, successful_checks, sum_total_time, date]}) { + affected_rows + } + } + ` + + endpoints = endpoints.map(endpoint => ({ + successful_checks: endpoint.isWorking, + sum_total_time: endpoint.time, + value: endpoint.value, + producer_id: endpoint.producer_id, + date: payload.date + })) + + await hasuraUtil.request(mutation, { payload, endpoints }) +} + +const updateEndpointsHealthHistory = async (endpoints, date) => { + const mutation = ` + mutation insert($date: date!,$updates: [endpoints_check_history_updates!]!) { + update_health_check_history(where: {date: {_eq: $date}}, _inc: {total_checks: 1}) { + affected_rows + } + update_endpoints_check_history_many(updates: $updates) { + affected_rows + } + } + ` + updates = endpoints.map(endpoint => ({ + where: { + _and: [{ value: { _eq: endpoint.value } }, { date: { _eq: date } }] + }, + _inc: { + successful_checks: endpoint.isWorking, + sum_total_time: endpoint.time + } + })) + + await hasuraUtil.request(mutation, { date, updates }) +} + +const clearEndpointsHealthHistory = async (limit) => { + const date = new Date() + + date.setHours(0, 0, 0, 0) + date.setDate(date.getDate() - limit) + + const mutation = ` + mutation clear($date: date){ + delete_endpoints_check_history(where: {date: {_eq: $date}}){ + affected_rows + } + } + ` + + await hasuraUtil.request(mutation, { date }) +} + +const saveHealthRegister = async endpoints => { + const today = new Date() + + today.setHours(0, 0, 0, 0) + + const query = ` + query($today: date){ + history: health_check_history_aggregate{ + aggregate{ + count + } + } + older: health_check_history(limit: 1, order_by: {date: asc}){ + id + } + current: health_check_history(limit: 1, where: {date: {_eq: $today}}){ + id + } + }` + + const limit = 30 + const { + older, + current, + history: { + aggregate: { count } + } + } = await hasuraUtil.request(query, { today }) + + if (current?.length) { + await updateEndpointsHealthHistory(endpoints, today) + } else { + const payload = { date: today, total_checks: 1 } + + if (count + 1 > limit) { + payload.id = older[0].id + } + + await newEndpointsHealthHistory(endpoints, payload) + await clearEndpointsHealthHistory(limit) + } +} + +module.exports = { + saveHealthRegister, + clearEndpointsHealthHistory +} diff --git a/hapi/src/services/index.js b/hapi/src/services/index.js index 69286ce9..42889a26 100644 --- a/hapi/src/services/index.js +++ b/hapi/src/services/index.js @@ -2,6 +2,7 @@ const cpuService = require('./cpu.service') const missedBlocksService = require('./missed-blocks.service') const producerService = require('./producer.service') const nodeService = require('./node.service') +const healthCheckHistoryService = require('./health-check-history.service') const settingService = require('./setting.service') const stateHistoryPluginService = require('./state-history-plugin.service') const statsService = require('./stats.service') @@ -14,6 +15,7 @@ module.exports = { missedBlocksService, producerService, nodeService, + healthCheckHistoryService, settingService, stateHistoryPluginService, statsService, diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index 935803fa..3f1c2127 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -1,3 +1,5 @@ +const { StatusCodes } = require('http-status-codes') + const { hasuraUtil, sequelizeUtil, producerUtil } = require('../utils') const { eosConfig } = require('../config') @@ -5,6 +7,7 @@ const lacchainService = require('./lacchain.service') const eosioService = require('./eosio.service') const nodeService = require('./node.service') const statsService = require('./stats.service') +const healthCheckHistoryService = require('./health-check-history.service') const updateBPJSONs = async (producers = []) => { const upsertMutation = ` @@ -137,18 +140,17 @@ const syncEndpoints = async () => { if (!count) return - const today = new Date() - - today.setHours(0,0,0,0) - let endpoints = await Promise.all( producers.map(async producer => { const endpoints = producer.nodes.flatMap(node => node?.endpoints || []) + const list = await endpointsHealth(endpoints) - return await endpointsHealth(endpoints) + return (list.map(endpoint => ({...endpoint,producer_id:producer.id}))) })) - endpoints = endpoints.flat() + endpoints = endpoints.flat() + + await healthCheckHistoryService.saveHealthRegister(endpoints) } const endpointsHealth = async endpoints => { @@ -166,7 +168,6 @@ const endpointsHealth = async endpoints => { endpoint.head_block_time = previous.head_block_time endpoint.updated_at = previous.updated_at }else{ - const startTime = new Date() const {nodeInfo, ...response} = await producerUtil.getNodeInfo( endpoint.value @@ -181,7 +182,7 @@ const endpointsHealth = async endpoints => { await nodeService.updateEndpointInfo(endpoint) if(!isRepeated){ - checkedList.push(endpoint) + checkedList.push({...endpoint,isWorking: Number(endpoint?.response?.status === StatusCodes.OK)}) } } From 233e5c55f7513c1f01899954f207eb0778f0fff6 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 15 Mar 2023 10:48:14 -0600 Subject: [PATCH 07/20] feat(hasura): add check history by endpoint view --- .../tables/public_check_history_by_endpoint.yaml | 3 +++ hasura/metadata/databases/default/tables/tables.yaml | 1 + .../down.sql | 12 ++++++++++++ .../up.sql | 10 ++++++++++ 4 files changed, 26 insertions(+) create mode 100644 hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml create mode 100644 hasura/migrations/default/1678832423904_add_check_history_by_endpoint/down.sql create mode 100644 hasura/migrations/default/1678832423904_add_check_history_by_endpoint/up.sql diff --git a/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml b/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml new file mode 100644 index 00000000..857ff38c --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml @@ -0,0 +1,3 @@ +table: + name: check_history_by_endpoint + schema: public diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 6b432c6b..0a6a467d 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -1,5 +1,6 @@ - "!include public_block_history.yaml" - "!include public_block_history_by_producer_type.yaml" +- "!include public_check_history_by_endpoint.yaml" - "!include public_cpu.yaml" - "!include public_demux_state.yaml" - "!include public_endpoint.yaml" diff --git a/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/down.sql b/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/down.sql new file mode 100644 index 00000000..cff2215f --- /dev/null +++ b/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/down.sql @@ -0,0 +1,12 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- CREATE +-- OR REPLACE VIEW "public"."check_history_by_endpoint" AS +-- SELECT producer_id, value, endpoints_check_history.date, total_checks, (sum_total_time / total_checks) as avg_time, ((successful_checks * 100) / total_checks) as availability +-- FROM +-- ( +-- endpoints_check_history +-- JOIN health_check_history ON ((endpoints_check_history.date = health_check_history.date)) +-- ) +-- ORDER BY endpoints_check_history.date ASC, availability DESC, avg_time ASC +-- ; diff --git a/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/up.sql b/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/up.sql new file mode 100644 index 00000000..f2a9d39c --- /dev/null +++ b/hasura/migrations/default/1678832423904_add_check_history_by_endpoint/up.sql @@ -0,0 +1,10 @@ +CREATE +OR REPLACE VIEW "public"."check_history_by_endpoint" AS +SELECT producer_id, value, endpoints_check_history.date, total_checks, (sum_total_time / total_checks) as avg_time, ((successful_checks * 100) / total_checks) as availability + FROM + ( + endpoints_check_history + JOIN health_check_history ON ((endpoints_check_history.date = health_check_history.date)) + ) + ORDER BY endpoints_check_history.date ASC, availability DESC, avg_time ASC + ; From 432b9c9a3f8b4927204d30cbd4d84dc4344482bf Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 15 Mar 2023 10:51:38 -0600 Subject: [PATCH 08/20] feat(hasura): add select permissions to guest role --- .../tables/public_check_history_by_endpoint.yaml | 11 +++++++++++ .../tables/public_endpoints_check_history.yaml | 11 +++++++++++ .../default/tables/public_health_check_history.yaml | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml b/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml index 857ff38c..62e01c05 100644 --- a/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml +++ b/hasura/metadata/databases/default/tables/public_check_history_by_endpoint.yaml @@ -1,3 +1,14 @@ table: name: check_history_by_endpoint schema: public +select_permissions: + - role: guest + permission: + columns: + - value + - date + - avg_time + - availability + - producer_id + - total_checks + filter: {} diff --git a/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml b/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml index b1badbbe..0f1283f3 100644 --- a/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml +++ b/hasura/metadata/databases/default/tables/public_endpoints_check_history.yaml @@ -1,3 +1,14 @@ table: name: endpoints_check_history schema: public +select_permissions: + - role: guest + permission: + columns: + - value + - date + - producer_id + - successful_checks + - sum_total_time + - id + filter: {} diff --git a/hasura/metadata/databases/default/tables/public_health_check_history.yaml b/hasura/metadata/databases/default/tables/public_health_check_history.yaml index 09677074..f873f3ed 100644 --- a/hasura/metadata/databases/default/tables/public_health_check_history.yaml +++ b/hasura/metadata/databases/default/tables/public_health_check_history.yaml @@ -1,3 +1,13 @@ table: name: health_check_history schema: public +select_permissions: + - role: guest + permission: + columns: + - date + - total_checks + - created_at + - updated_at + - id + filter: {} From bff30f604a2c1783d631784055b808821d8d5e97 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Mon, 20 Mar 2023 10:26:28 -0600 Subject: [PATCH 09/20] feat(webapp): add endpoints stats view --- webapp/src/gql/producer.gql.js | 19 ++++ .../customHooks/useHealthCheckHistoryState.js | 84 +++++++++++++++ .../EndpointsStats/EndpointStatsTable.js | 51 +++++++++ webapp/src/routes/EndpointsStats/index.js | 102 ++++++++++++++++++ webapp/src/routes/EndpointsStats/styles.js | 8 ++ webapp/src/routes/index.js | 8 ++ 6 files changed, 272 insertions(+) create mode 100644 webapp/src/hooks/customHooks/useHealthCheckHistoryState.js create mode 100644 webapp/src/routes/EndpointsStats/EndpointStatsTable.js create mode 100644 webapp/src/routes/EndpointsStats/index.js create mode 100644 webapp/src/routes/EndpointsStats/styles.js diff --git a/webapp/src/gql/producer.gql.js b/webapp/src/gql/producer.gql.js index afe2db5a..1e3df9f8 100644 --- a/webapp/src/gql/producer.gql.js +++ b/webapp/src/gql/producer.gql.js @@ -210,3 +210,22 @@ export const EOSRATE_STATS_QUERY = gql` } } ` + +export const FASTEST_ENDPOINTS_QUERY = gql`query($today: date){ + endpoints: check_history_by_endpoint(limit: 5, order_by: {avg_time: asc, availability: desc}, where: {date: {_eq: $today}}) { + value + avg_time + availability + } +}` + +export const HISTORY_ENDPOINTS_BY_PRODUCER_QUERY = gql`query($id: Int){ + endpoints: check_history_by_endpoint(order_by: {value: asc, date: asc}, where: {producer_id: {_eq: $id}}) { + value + date + avg_time + availability + } +}` + + diff --git a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js new file mode 100644 index 00000000..fd0a7bb8 --- /dev/null +++ b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js @@ -0,0 +1,84 @@ +import { useState, useEffect } from 'react' +import { useLazyQuery } from '@apollo/client' + +import { + FASTEST_ENDPOINTS_QUERY, + HISTORY_ENDPOINTS_BY_PRODUCER_QUERY, + PRODUCERS_QUERY, +} from '../../gql' + +const useHealthCheckState = () => { + const [ + loadEndpoints, + { loading = true, data: { endpoints: fastestEndpoints } = {} }, + ] = useLazyQuery(FASTEST_ENDPOINTS_QUERY) + const [ + loadProducers, + { loading: loadingProducers = true, data: { producers } = {} }, + ] = useLazyQuery(PRODUCERS_QUERY) + const [ + loadHistory, + { loading: loadingHistory = true, data: { endpoints: history } = {} }, + ] = useLazyQuery(HISTORY_ENDPOINTS_BY_PRODUCER_QUERY) + const [producersNames, setProducersNames] = useState() + const [selected, setSelected] = useState() + const [historyData, setHistoryData] = useState() + const [statsAverage, setStatsAverage] = useState() + + useEffect(() => { + const endpointFilter = { + _and: [{ type: { _in: ['ssl', 'api'] } }, { value: { _gt: '' } }], + } + loadProducers({ + variables: { + where: { nodes: { endpoints: endpointFilter } }, + endpointFilter, + limit: null, + }, + }) + loadEndpoints({ variables: { today: new Date() } }) + }, []) + + useEffect(() => { + if (!producers?.length) return + + setProducersNames( + producers.map((producer) => ({ + id: producer.id, + name: producer?.bp_json?.org?.candidate_name, + })), + ) + setSelected(producers[0]?.id) + }, [producers]) + + useEffect(() => { + loadHistory({ variables: { id: selected } }) + }, [selected]) + + useEffect(() => { + if (!history) return + + const data = history.reduce((aux, curr) => { + const index = aux.findIndex((x) => x.name === curr.value) + if (index < 0) { + aux.push({ name: curr.value, data: [curr.avg_time],avg_time:curr.avg_time, availability: curr.availability}) + } else { + aux[index].data.push(curr.avg_time) + aux[index].availability = aux[index].availability + curr.availability + aux[index].avg_time = aux[index].avg_time + curr.avg_time + } + + return aux + }, []) + setHistoryData(data) + setStatsAverage(data.map(x=>({value:x.name,avg_time:x.avg_time/x.data.length,availability:x.availability/x.data.length}))) + + }, [history]) + + return [ + { fastestEndpoints, producersNames, historyData, statsAverage, selected, loading }, + { setSelected }, + ] +} + +export default useHealthCheckState diff --git a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js new file mode 100644 index 00000000..3dd521ab --- /dev/null +++ b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js @@ -0,0 +1,51 @@ +/* eslint camelcase: 0 */ +import React from 'react' +import { useTranslation } from 'react-i18next' +import Typography from '@mui/material/Typography' +import Table from '@mui/material/Table' +import TableBody from '@mui/material/TableBody' +import TableCell from '@mui/material/TableCell' +import TableContainer from '@mui/material/TableContainer' +import TableHead from '@mui/material/TableHead' +import TableRow from '@mui/material/TableRow' + +import { makeStyles } from '@mui/styles' + +import styles from './styles' + +const useStyles = makeStyles(styles) + +const EndpointsTable = ({endpoints, title}) => { + const { t } = useTranslation('EndpointsStatsRoute') + const classes = useStyles() + + return ( + <> + + {title} + + + + + + {t('Endpoint')} + {t('Average Availability')} + {t('Average Response Time')} + + + + {endpoints.map((item, index) => ( + + {item.value} + {`${item.availability}%`} + {`${item.avg_time.toFixed(3)} s`} + + ))} + +
+
+ + ) +} + +export default EndpointsTable diff --git a/webapp/src/routes/EndpointsStats/index.js b/webapp/src/routes/EndpointsStats/index.js new file mode 100644 index 00000000..f2d81155 --- /dev/null +++ b/webapp/src/routes/EndpointsStats/index.js @@ -0,0 +1,102 @@ +/* eslint camelcase: 0 */ +import React from 'react' +import { useTranslation } from 'react-i18next' +import Card from '@mui/material/Card' +import CardContent from '@mui/material/CardContent' +import Typography from '@mui/material/Typography' +import LinearProgress from '@mui/material/LinearProgress' +import MenuItem from '@mui/material/MenuItem' +import Highcharts from 'highcharts' +import HighchartsReact from 'highcharts-react-official' +import moment from 'moment' +import Select from '@mui/material/Select' +import { makeStyles } from '@mui/styles' + +import useHealthCheckState from '../../hooks/customHooks/useHealthCheckHistoryState' + +import styles from './styles' +import EndpointsTable from './EndpointStatsTable' + +const useStyles = makeStyles(styles) + +const dates = [] +for (let i = 29; i >= 0; i--) { + const d = moment().subtract(i, 'days').format('ll') + dates.push(d) +} + +const options = { + xAxis: { + categories: dates, + }, + credits: { + enabled: false, + }, + title: { + text: 'Average Response Time', + }, + yAxis: { + title: { + text: 'Time in seconds', + }, + labels: { + format: '{text} s', + }, + }, + tooltip: { + pointFormat: '{series.name}: {point.y} s', + }, +} + +const EndpointsStats = () => { + const { t } = useTranslation('EndpointsStatsRoute') + const classes = useStyles() + const [{fastestEndpoints,producersNames,historyData,statsAverage,selected,loading},{setSelected}] = useHealthCheckState() + + return ( + <> + + + {loading && } + {!loading && ( + + )} + + + + + + Endpoints stats by producer + +
+ {producersNames?.length && ( + + )} + {historyData && ( + + )} + {statsAverage && ( + + )} +
+
+ + ) +} + +export default EndpointsStats diff --git a/webapp/src/routes/EndpointsStats/styles.js b/webapp/src/routes/EndpointsStats/styles.js new file mode 100644 index 00000000..342f4ff9 --- /dev/null +++ b/webapp/src/routes/EndpointsStats/styles.js @@ -0,0 +1,8 @@ +export default (theme) => ({ + cardShadow: { + boxShadow: '0px 1px 3px 1px rgba(0, 0, 0, 0.15) !important', + }, + cardByProducer: { + marginTop: theme.spacing(8) + } +}) diff --git a/webapp/src/routes/index.js b/webapp/src/routes/index.js index 5267c2f0..cfd29912 100644 --- a/webapp/src/routes/index.js +++ b/webapp/src/routes/index.js @@ -27,6 +27,7 @@ import { const Home = lazy(() => import('./Home')) const CPUBenchmark = lazy(() => import('./CPUBenchmark')) +const EndpointsStats = lazy(() => import('./EndpointsStats')) const BlockProducers = lazy(() => import('./BlockProducers')) const RewardsDistribution = lazy(() => import('./RewardsDistribution')) const Nodes = lazy(() => import('./Nodes')) @@ -118,6 +119,13 @@ const defaultRoutes = [ path: '/cpu-benchmark', exact: true, }, + { + name: 'endpointsStats', + icon: , + component: EndpointsStats, + path: '/endpoints-stats', + exact: true, + }, { name: 'ricardianContract', icon: , From b61ba3916751b4ccccfb9030776baab9aac8a921 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Mon, 20 Mar 2023 13:49:39 -0600 Subject: [PATCH 10/20] feat(webapp): add internationalization for endpoints stats view --- .../customHooks/useHealthCheckHistoryState.js | 58 +++++++++++++----- webapp/src/language/en.json | 11 ++++ webapp/src/language/en.jungle.json | 2 + webapp/src/language/en.lacchain.json | 2 + webapp/src/language/en.libre-testnet.json | 2 + webapp/src/language/en.libre.json | 2 + webapp/src/language/en.mainnet.json | 2 + webapp/src/language/en.proton-testnet.json | 2 + webapp/src/language/en.proton.json | 2 + webapp/src/language/en.telos-testnet.json | 2 + webapp/src/language/en.telos.json | 2 + webapp/src/language/en.ultra-testnet.json | 2 + webapp/src/language/en.wax-testnet.json | 2 + webapp/src/language/en.wax.json | 2 + webapp/src/language/es.json | 11 ++++ webapp/src/language/es.jungle.json | 2 + webapp/src/language/es.lacchain.json | 2 + webapp/src/language/es.libre-testnet.json | 2 + webapp/src/language/es.libre.json | 2 + webapp/src/language/es.mainnet.json | 2 + webapp/src/language/es.proton-testnet.json | 2 + webapp/src/language/es.proton.json | 2 + webapp/src/language/es.telos-testnet.json | 2 + webapp/src/language/es.telos.json | 2 + webapp/src/language/es.ultra-testnet.json | 2 + webapp/src/language/es.wax-testnet.json | 2 + webapp/src/language/es.wax.json | 2 + .../EndpointsStats/EndpointStatsTable.js | 11 +--- webapp/src/routes/EndpointsStats/index.js | 60 +++++++++---------- 29 files changed, 141 insertions(+), 58 deletions(-) diff --git a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js index fd0a7bb8..f5bb7db8 100644 --- a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js +++ b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js @@ -24,6 +24,7 @@ const useHealthCheckState = () => { const [selected, setSelected] = useState() const [historyData, setHistoryData] = useState() const [statsAverage, setStatsAverage] = useState() + const [dates, setDates] = useState() useEffect(() => { const endpointFilter = { @@ -37,7 +38,7 @@ const useHealthCheckState = () => { }, }) loadEndpoints({ variables: { today: new Date() } }) - }, []) + }, [loadProducers, loadEndpoints]) useEffect(() => { if (!producers?.length) return @@ -52,31 +53,56 @@ const useHealthCheckState = () => { }, [producers]) useEffect(() => { + if (!selected) return + loadHistory({ variables: { id: selected } }) - }, [selected]) + }, [loadHistory, selected]) useEffect(() => { if (!history) return const data = history.reduce((aux, curr) => { - const index = aux.findIndex((x) => x.name === curr.value) - if (index < 0) { - aux.push({ name: curr.value, data: [curr.avg_time],avg_time:curr.avg_time, availability: curr.availability}) - } else { - aux[index].data.push(curr.avg_time) - aux[index].availability = aux[index].availability + curr.availability - aux[index].avg_time = aux[index].avg_time + curr.avg_time - } - - return aux - }, []) + const index = aux.findIndex(x => x.name === curr.value) + if (index < 0) { + aux.push({ + name: curr.value, + data: [curr.avg_time], + dates: [curr.date], + avg_time: curr.avg_time, + availability: curr.availability, + }) + } else { + aux[index].data.push(curr.avg_time) + aux[index].availability = aux[index].availability + curr.availability + aux[index].avg_time = aux[index].avg_time + curr.avg_time + aux[index].dates.push(curr.date) + } + + return aux + }, []) + setDates(data[0]?.dates || []) setHistoryData(data) - setStatsAverage(data.map(x=>({value:x.name,avg_time:x.avg_time/x.data.length,availability:x.availability/x.data.length}))) - + setStatsAverage( + data.map(x => ({ + value: x.name, + avg_time: x.avg_time / x.data.length, + availability: x.availability / x.data.length, + })), + ) }, [history]) return [ - { fastestEndpoints, producersNames, historyData, statsAverage, selected, loading }, + { + fastestEndpoints, + producersNames, + historyData, + statsAverage, + selected, + dates, + loading, + loadingHistory, + loadingProducers + }, { setSelected }, ] } diff --git a/webapp/src/language/en.json b/webapp/src/language/en.json index 6cb61a2c..186928f5 100644 --- a/webapp/src/language/en.json +++ b/webapp/src/language/en.json @@ -89,6 +89,9 @@ "/endpoints>sidebar": "API Endpoints", "/endpoints>title": "API Endpoints - EOSIO + Antelope Network Dashboard", "/endpoints>heading": "API Endpoints", + "/endpoints-stats>sidebar": "API Endpoints Stats", + "/endpoints-stats>title": "API Endpoints Stats- EOSIO + Antelope Network Dashboard", + "/endpoints-stats>heading": "API Endpoints Stats", "/about>sidebar": "About", "/about>title": "About - EOSIO + Antelope Network Dashboard", "/about>heading": "About", @@ -385,5 +388,13 @@ }, "mainMapComponent": { "numberOfNodes": "Number of Nodes" + }, + "EndpointsStatsRoute": { + "fastest": "Top 5 fastest endpoints by querying from Costa Rica", + "byProducer": "Endpoints stats by producer", + "avgAvailability": "Average Availability", + "avgTime": "Average Response Time", + "list": "List of endpoints", + "timeInSecs": "Time in seconds" } } diff --git a/webapp/src/language/en.jungle.json b/webapp/src/language/en.jungle.json index 044dba6b..383886cd 100644 --- a/webapp/src/language/en.jungle.json +++ b/webapp/src/language/en.jungle.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Jungle4 Testnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - Jungle4 Testnet Network Dashboard", "/endpoints>title": "API Endpoints - Jungle4 Testnet Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats - Jungle4 Testnet Network Dashboard", "/about>title": "About - Jungle4 Testnet Network Dashboard", "/help>title": "Help - Jungle4 Testnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.lacchain.json b/webapp/src/language/en.lacchain.json index a2e1d983..41395054 100644 --- a/webapp/src/language/en.lacchain.json +++ b/webapp/src/language/en.lacchain.json @@ -29,6 +29,7 @@ "/nodes>title": "LACChain EOSIO Nodes Status Monitor", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>title": "Geographic Distribution of Nodes - LACChain EOSIO + Antelope Network Dashboard", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>title": "Accounts and Contracts - LACChain EOSIO + Antelope Network Dashboard", @@ -40,6 +41,7 @@ "/missed-blocks>title": "Missed Blocks - LACChain EOSIO + Antelope Network Dashboard", "/missed-blocks>moreDescription": "A list of scheduled, produced, and missed blocks by each account in the network.", "/endpoints>title": "API Endpoints - LACChain EOSIO + Antelope Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- LACChain EOSIO + Antelope Network Dashboard", "/about>title": "About - LACChain EOSIO + Antelope Network Dashboard", "/help>title": "Help - LACChain EOSIO + Antelope Network Dashboard" }, diff --git a/webapp/src/language/en.libre-testnet.json b/webapp/src/language/en.libre-testnet.json index a6f25bb7..86534a59 100644 --- a/webapp/src/language/en.libre-testnet.json +++ b/webapp/src/language/en.libre-testnet.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Libre Testnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - Libre Testnet Network Dashboard", "/endpoints>title": "API Endpoints - Libre Testnet Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- Libre Testnet Network Dashboard", "/about>title": "About - Libre Testnet Network Dashboard", "/help>title": "Help - Libre Testnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -26,6 +27,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.libre.json b/webapp/src/language/en.libre.json index 23c33162..68943ceb 100644 --- a/webapp/src/language/en.libre.json +++ b/webapp/src/language/en.libre.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Libre Mainnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - Libre Mainnet Network Dashboard", "/endpoints>title": "API Endpoints - Libre Mainnet Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- Libre Mainnet Network Dashboard", "/about>title": "About - Libre Mainnet Network Dashboard", "/help>title": "Help - Libre Mainnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -26,6 +27,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.mainnet.json b/webapp/src/language/en.mainnet.json index c1c4b9cd..5edcc8da 100644 --- a/webapp/src/language/en.mainnet.json +++ b/webapp/src/language/en.mainnet.json @@ -12,6 +12,7 @@ "/block-distribution>title": "Block Production Distribution - EOS Network Monitor", "/missed-blocks>title": "Missed Blocks - EOS Network Monitor", "/endpoints>title": "API Endpoints - EOS Network Monitor", + "/endpoints-stats>title": "API Endpoints Stats- EOS Network Monitor", "/about>title": "About - EOS Network Monitor", "/help>title": "Help - EOS Network Monitor", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -24,6 +25,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.proton-testnet.json b/webapp/src/language/en.proton-testnet.json index 38177f24..8e6b3434 100644 --- a/webapp/src/language/en.proton-testnet.json +++ b/webapp/src/language/en.proton-testnet.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Proton Testnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - Proton Testnet Network Dashboard", "/endpoints>title": "API Endpoints - Proton Testnet Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- Proton Testnet Network Dashboard", "/about>title": "About - Proton Testnet Network Dashboard", "/help>title": "Help - Proton Testnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.proton.json b/webapp/src/language/en.proton.json index f673cae1..90faa2e5 100644 --- a/webapp/src/language/en.proton.json +++ b/webapp/src/language/en.proton.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Proton Network Dashboard", "/missed-blocks>title": "Missed Blocks - Proton Network Dashboard", "/endpoints>title": "API Endpoints - Proton Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- Proton Network Dashboard", "/about>title": "About - Proton Network Dashboard", "/help>title": "Help - Proton Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.telos-testnet.json b/webapp/src/language/en.telos-testnet.json index 102cd3ef..c4f4850a 100644 --- a/webapp/src/language/en.telos-testnet.json +++ b/webapp/src/language/en.telos-testnet.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Telos Testnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - Telos Testnet Network Dashboard", "/endpoints>title": "API Endpoints - Telos Testnet Network Dashboard", + "/endpoints-Stats>title": "API Endpoints Stats- Telos Testnet Network Dashboard", "/about>title": "About - Telos Testnet Network Dashboard", "/help>title": "Help - Telos Testnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.telos.json b/webapp/src/language/en.telos.json index 3b811eab..15935114 100644 --- a/webapp/src/language/en.telos.json +++ b/webapp/src/language/en.telos.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - Telos Network Dashboard", "/missed-blocks>title": "Missed Blocks - Telos Network Dashboard", "/endpoints>title": "API Endpoints - Telos Network Dashboard", + "/endpoints-stats>title": "API Endpoints Stats- Telos Network Dashboard", "/about>title": "About - Telos Network Dashboard", "/help>title": "Help - Telos Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.ultra-testnet.json b/webapp/src/language/en.ultra-testnet.json index 9d4a7b8e..e295655a 100644 --- a/webapp/src/language/en.ultra-testnet.json +++ b/webapp/src/language/en.ultra-testnet.json @@ -14,6 +14,7 @@ "/block-distribution>title": "Block Production Distribution - Ultra Testnet Dashboard", "/missed-blocks>title": "Missed Blocks - Ultra Testnet Dashboard", "/endpoints>title": "API Endpoints - Ultra Testnet Dashboard", + "/endpoints-Stats>title": "API Endpoints Stats- Ultra Testnet Dashboard", "/about>title": "About - Ultra Testnet Dashboard", "/help>title": "Help - Ultra Testnet Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -27,6 +28,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.wax-testnet.json b/webapp/src/language/en.wax-testnet.json index b02ef072..c3e973f2 100644 --- a/webapp/src/language/en.wax-testnet.json +++ b/webapp/src/language/en.wax-testnet.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - WAX Testnet Network Dashboard", "/missed-blocks>title": "Missed Blocks - WAX Testnet Network Dashboard", "/endpoints>title": "API Endpoints - WAX Testnet Network Dashboard", + "/endpoints-Stats>title": "API Endpoints Stats - WAX Testnet Network Dashboard", "/about>title": "About - WAX Testnet Network Dashboard", "/help>title": "Help - WAX Testnet Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/en.wax.json b/webapp/src/language/en.wax.json index 76b2ee3b..f17baebc 100644 --- a/webapp/src/language/en.wax.json +++ b/webapp/src/language/en.wax.json @@ -13,6 +13,7 @@ "/block-distribution>title": "Block Production Distribution - WAX Network Dashboard", "/missed-blocks>title": "Missed Blocks - WAX Network Dashboard", "/endpoints>title": "API Endpoints - WAX Network Dashboard", + "/endpoints-Stats>title": "API Endpoints Stats- WAX Network Dashboard", "/about>title": "About - WAX Network Dashboard", "/help>title": "Help - WAX Network Dashboard", "/rewards-distribution>moreDescription": "A geographic visualization of daily block producer rewards and a list of undiscoverable paid block producers.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "A list of the block producers in the network – blockchain accounts registered to run nodes on the network. It includes information from chain tables and their bp.json files.", "/nodes>moreDescription": "A list of all the nodes run by block producers comprising the network with specific information such as endpoints and location.", "/endpoints>moreDescription": "An updated list of public API endpoints provided by node operators and their health status.", + "/endpoints-stats>moreDescription": "Response time statistics from Costa Rica and the availability of a producer's endpoints.", "/nodes-distribution>moreDescription": "A visualization of the geographic distribution of the nodes in this network.", "/accounts>moreDescription": "This tool helps find information about accounts and interact with contracts on the network. Enter an account name and obtain account information, smart contract actions, and table data.", "/block-distribution>moreDescription": "A visualization of the distribution of blocks produced by the nodes in the network.", diff --git a/webapp/src/language/es.json b/webapp/src/language/es.json index 7db8bec0..a47b25a7 100644 --- a/webapp/src/language/es.json +++ b/webapp/src/language/es.json @@ -97,6 +97,9 @@ "/endpoints>sidebar": "URL's", "/endpoints>title": "URL's - Antelope Tools", "/endpoints>heading": "URL's", + "/endpoints-stats>sidebar": "Estadísticas de URL's", + "/endpoints-stats>title": "Estadísticas de URL's - Antelope Tools", + "/endpoints-stats>heading": "Estadísticas de puntos finales", "/about>sidebar": "Acerca de", "/about>title": "Acerca de - Panel", "/about>heading": "Acerca de", @@ -402,5 +405,13 @@ }, "mainMapComponent": { "numberOfNodes": "Cantidad de Nodos" + }, + "EndpointsStatsRoute": { + "fastest": "Top 5 puntos finales más rápidos desde Costa Rica", + "byProducer": "Estadísticas de puntos finales por productor", + "avgAvailability": "Disponibilidad promedio", + "avgTime": "Tiempo de respuesta promedio", + "list": "Lista de puntos finales", + "timeInSecs": "Tiempo en segundos" } } diff --git a/webapp/src/language/es.jungle.json b/webapp/src/language/es.jungle.json index 2df1abca..bfe25528 100644 --- a/webapp/src/language/es.jungle.json +++ b/webapp/src/language/es.jungle.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Jungle4 Testnet", "/block-distribution>title": "Distribución de bloques - Jungle4 Testnet", "/endpoints>title": "URL's - Jungle4 Testnet", + "/endpoints-stats>title": "Estadísticas de URL's - Jungle4 Testnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Una lista de entidades que forman parte de la red. Pueden ser entidades asociadas o no asociadas.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.lacchain.json b/webapp/src/language/es.lacchain.json index e0538bac..01689b46 100644 --- a/webapp/src/language/es.lacchain.json +++ b/webapp/src/language/es.lacchain.json @@ -25,6 +25,7 @@ "/bpjson>title": "BP JSON - Panel", "/block-distribution>title": "Distribución de bloques - LACChain EOSIO", "/endpoints>title": "URL's - LACChain EOSIO", + "/endpoints-stats>title": "Estadísticas de URL's - WAX", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/entities>moreDescription": "Una lista de entidades que forman parte de la red. Pueden ser entidades socias o no socias.", @@ -37,6 +38,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.libre-testnet.json b/webapp/src/language/es.libre-testnet.json index b8fda635..fb8a1c8f 100644 --- a/webapp/src/language/es.libre-testnet.json +++ b/webapp/src/language/es.libre-testnet.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Libre Testnet", "/block-distribution>title": "Distribución de bloques - Libre Testnet", "/endpoints>title": "URL's - Libre Testnet", + "/endpoints-stats>title": "Estadísticas de URL's - Libre Testnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -24,6 +25,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.libre.json b/webapp/src/language/es.libre.json index 78588524..f348d8f3 100644 --- a/webapp/src/language/es.libre.json +++ b/webapp/src/language/es.libre.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Libre Mainnet", "/block-distribution>title": "Distribución de bloques - Libre Mainnet", "/endpoints>title": "URL's - Libre Mainnet", + "/endpoints>title-stats": "URL's - Libre Mainnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -24,6 +25,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.mainnet.json b/webapp/src/language/es.mainnet.json index fe6136e3..4646151f 100644 --- a/webapp/src/language/es.mainnet.json +++ b/webapp/src/language/es.mainnet.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - EOS Mainnet", "/block-distribution>title": "Distribución de bloques - EOS Mainnet", "/endpoints>title": "URL's - EOS Mainnet", + "/endpoints-stats>title": "Estadísticas de URL's - EOS Mainnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.proton-testnet.json b/webapp/src/language/es.proton-testnet.json index 7c48b4a3..a421ce87 100644 --- a/webapp/src/language/es.proton-testnet.json +++ b/webapp/src/language/es.proton-testnet.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Proton Testnet", "/block-distribution>title": "Distribución de bloques - Proton Testnet", "/endpoints>title": "URL's - Proton Testnet", + "/endpoints-stats>title": "Estadísticas de URL's - Proton Testnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -22,6 +23,7 @@ "/cpu-benchmark>moreDescription": "Una visualización del uso de CPU en milisegundos por cuentas de nodos productores de bloques, con datos de uso más bajos, más altos y promedio.", "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", diff --git a/webapp/src/language/es.proton.json b/webapp/src/language/es.proton.json index 68531091..9b98b098 100644 --- a/webapp/src/language/es.proton.json +++ b/webapp/src/language/es.proton.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Proton", "/block-distribution>title": "Distribución de bloques - Proton", "/endpoints>title": "URL's - Proton", + "/endpoints-stats>title": "Estadísticas de URL's - Proton", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.telos-testnet.json b/webapp/src/language/es.telos-testnet.json index 43eee4dd..2b357643 100644 --- a/webapp/src/language/es.telos-testnet.json +++ b/webapp/src/language/es.telos-testnet.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Telos Testnet", "/block-distribution>title": "Distribución de bloques - Telos Testnet", "/endpoints>title": "URL's - Telos Testnet", + "/endpoints-stats>title": "Estadísticas de URL's - Telos Testnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.telos.json b/webapp/src/language/es.telos.json index d2747bc9..81234db2 100644 --- a/webapp/src/language/es.telos.json +++ b/webapp/src/language/es.telos.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Telos", "/block-distribution>title": "Distribución de bloques - Telos", "/endpoints>title": "URL's - Telos", + "/endpoints-stats>title": "Estadísticas de URL's - Telos", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.ultra-testnet.json b/webapp/src/language/es.ultra-testnet.json index 627af351..b389eb9a 100644 --- a/webapp/src/language/es.ultra-testnet.json +++ b/webapp/src/language/es.ultra-testnet.json @@ -12,6 +12,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - Ultra", "/block-distribution>title": "Distribución de bloques - Ultra", "/endpoints>title": "URL's - Ultra", + "/endpoints-stats>title": "Estadísticas de URL's - Ultra", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -25,6 +26,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.wax-testnet.json b/webapp/src/language/es.wax-testnet.json index f45d8c26..0e9f5f4a 100644 --- a/webapp/src/language/es.wax-testnet.json +++ b/webapp/src/language/es.wax-testnet.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - WAX Testnet", "/block-distribution>title": "Distribución de bloques - WAX Testnet", "/endpoints>title": "URL's - WAX Testnet", + "/endpoints-stats>title": "Estadísticas de URL's - WAX Testnet", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/language/es.wax.json b/webapp/src/language/es.wax.json index e2557146..9868b439 100644 --- a/webapp/src/language/es.wax.json +++ b/webapp/src/language/es.wax.json @@ -11,6 +11,7 @@ "/ricardian-contract>title": "Acuerdo de Productor de Bloques - WAX", "/block-distribution>title": "Distribución de bloques - WAX", "/endpoints>title": "URL's - WAX", + "/endpoints-stats>title": "Estadísticas de URL's - WAX", "/about>title": "Acerca de - Panel", "/help>title": "Ayuda - Panel", "/rewards-distribution>moreDescription": "Distribución diaria de recompensas de BP por ubicación geográfica de los productores de bloques pagados.", @@ -23,6 +24,7 @@ "/block-producers>moreDescription": "Una lista de los productores de bloques en la red: cuentas de blockchain registradas para ejecutar nodos en la red. Incluye información de tablas en cadena y sus archivos bp.json.", "/nodes>moreDescription": "Una lista de todos los nodos ejecutados por entidades que componen la red con información específica como puntos finales y ubicación.", "/endpoints>moreDescription": "Una lista actualizada de los puntos finales de la API pública proporcionada por los operadores de nodos en la red.", + "/endpoints-stats>moreDescription": "Estadísticas del tiempo de respuesta desde Costa Rica y la disponibilidad de los puntos finales de un productor", "/nodes-distribution>moreDescription": "Una visualización de la distribución geográfica de los nodos de esta red.", "/accounts>moreDescription": "Esta herramienta le ayuda a buscar información sobre cuentas y contratos de la red. Escriba el nombre de un contrato o cuenta en el espacio provisto para comenzar a buscar. Obtendrá los datos de las acciones del contrato, tablas de contrato, alcance, límites superior e inferior y límites.", "/block-distribution>moreDescription": "Una visualización de la distribución de bloques producida por los nodos de la red.", diff --git a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js index 3dd521ab..686a8e70 100644 --- a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js +++ b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js @@ -9,15 +9,8 @@ import TableContainer from '@mui/material/TableContainer' import TableHead from '@mui/material/TableHead' import TableRow from '@mui/material/TableRow' -import { makeStyles } from '@mui/styles' - -import styles from './styles' - -const useStyles = makeStyles(styles) - const EndpointsTable = ({endpoints, title}) => { const { t } = useTranslation('EndpointsStatsRoute') - const classes = useStyles() return ( <> @@ -29,8 +22,8 @@ const EndpointsTable = ({endpoints, title}) => { {t('Endpoint')} - {t('Average Availability')} - {t('Average Response Time')} + {t('avgAvailability')} + {t('avgTime')} diff --git a/webapp/src/routes/EndpointsStats/index.js b/webapp/src/routes/EndpointsStats/index.js index f2d81155..acf37690 100644 --- a/webapp/src/routes/EndpointsStats/index.js +++ b/webapp/src/routes/EndpointsStats/index.js @@ -19,39 +19,33 @@ import EndpointsTable from './EndpointStatsTable' const useStyles = makeStyles(styles) -const dates = [] -for (let i = 29; i >= 0; i--) { - const d = moment().subtract(i, 'days').format('ll') - dates.push(d) -} +const EndpointsStats = () => { + const { t } = useTranslation('EndpointsStatsRoute') + const classes = useStyles() + const [{fastestEndpoints,producersNames,historyData,dates,statsAverage,selected,loading},{setSelected}] = useHealthCheckState() -const options = { - xAxis: { - categories: dates, - }, - credits: { - enabled: false, - }, - title: { - text: 'Average Response Time', - }, - yAxis: { + const options = { + xAxis: { + categories: dates, + }, + credits: { + enabled: false, + }, title: { - text: 'Time in seconds', + text: t('avgTime'), }, - labels: { - format: '{text} s', + yAxis: { + title: { + text: t('timeInSecs'), + }, + labels: { + format: '{text} s', + }, }, - }, - tooltip: { - pointFormat: '{series.name}: {point.y} s', - }, -} - -const EndpointsStats = () => { - const { t } = useTranslation('EndpointsStatsRoute') - const classes = useStyles() - const [{fastestEndpoints,producersNames,historyData,statsAverage,selected,loading},{setSelected}] = useHealthCheckState() + tooltip: { + pointFormat: '{series.name}: {point.y} s', + }, + } return ( <> @@ -60,7 +54,7 @@ const EndpointsStats = () => { {loading && } {!loading && ( )} @@ -69,7 +63,7 @@ const EndpointsStats = () => { - Endpoints stats by producer + {t('byProducer')}
{producersNames?.length && ( @@ -83,13 +77,13 @@ const EndpointsStats = () => { moment(x).format('ll')), }, series: historyData }} /> )} {statsAverage && ( )} From d18cde48eef14ad87fc109919dac9ff6169fedf0 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 22 Mar 2023 09:20:09 -0600 Subject: [PATCH 11/20] fix(hasura): remove check_history_by_endpoint view --- hasura/metadata/databases/default/tables/tables.yaml | 1 - .../down.sql | 3 +++ .../up.sql | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/down.sql create mode 100644 hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/up.sql diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 0a6a467d..6b432c6b 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -1,6 +1,5 @@ - "!include public_block_history.yaml" - "!include public_block_history_by_producer_type.yaml" -- "!include public_check_history_by_endpoint.yaml" - "!include public_cpu.yaml" - "!include public_demux_state.yaml" - "!include public_endpoint.yaml" diff --git a/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/down.sql b/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/down.sql new file mode 100644 index 00000000..5cb119fa --- /dev/null +++ b/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/down.sql @@ -0,0 +1,3 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- DROP VIEW "public"."check_history_by_endpoint"; diff --git a/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/up.sql b/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/up.sql new file mode 100644 index 00000000..abb5c4f1 --- /dev/null +++ b/hasura/migrations/default/1679498299922_drop_view_public_check_history_by_endpoint/up.sql @@ -0,0 +1 @@ +DROP VIEW "public"."check_history_by_endpoint"; From f47923591c140cef6c0368881567196dc4e15e76 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 22 Mar 2023 09:36:00 -0600 Subject: [PATCH 12/20] fix(hasura): change sum_total_time data type --- hasura/metadata/databases/default/tables/tables.yaml | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 1 + .../up.sql | 1 + .../down.sql | 12 ++++++++++++ .../up.sql | 10 ++++++++++ 7 files changed, 27 insertions(+) create mode 100644 hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql create mode 100644 hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql create mode 100644 hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql create mode 100644 hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql create mode 100644 hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/down.sql create mode 100644 hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/up.sql diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 6b432c6b..0a6a467d 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -1,5 +1,6 @@ - "!include public_block_history.yaml" - "!include public_block_history_by_producer_type.yaml" +- "!include public_check_history_by_endpoint.yaml" - "!include public_cpu.yaml" - "!include public_demux_state.yaml" - "!include public_endpoint.yaml" diff --git a/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql b/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql new file mode 100644 index 00000000..7e44662c --- /dev/null +++ b/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."endpoints_check_history" ALTER COLUMN "sum_total_time" TYPE real; diff --git a/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql b/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql new file mode 100644 index 00000000..33192ef4 --- /dev/null +++ b/hasura/migrations/default/1679498440162_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."endpoints_check_history" ALTER COLUMN "sum_total_time" TYPE int4; diff --git a/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql b/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql new file mode 100644 index 00000000..853f3c91 --- /dev/null +++ b/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/down.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."endpoints_check_history" ALTER COLUMN "sum_total_time" TYPE integer; diff --git a/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql b/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql new file mode 100644 index 00000000..503f88c8 --- /dev/null +++ b/hasura/migrations/default/1679498497399_alter_table_public_endpoints_check_history_alter_column_sum_total_time/up.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."endpoints_check_history" ALTER COLUMN "sum_total_time" TYPE float4; diff --git a/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/down.sql b/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/down.sql new file mode 100644 index 00000000..1f319e1b --- /dev/null +++ b/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/down.sql @@ -0,0 +1,12 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- CREATE OR REPLACE VIEW "public"."check_history_by_endpoint" AS +-- SELECT endpoints_check_history.producer_id, +-- endpoints_check_history.value, +-- endpoints_check_history.date, +-- health_check_history.total_checks, +-- (endpoints_check_history.sum_total_time / (health_check_history.total_checks))::real AS avg_time, +-- ((endpoints_check_history.successful_checks * 100) / health_check_history.total_checks) AS availability +-- FROM (endpoints_check_history +-- JOIN health_check_history ON ((endpoints_check_history.date = health_check_history.date))) +-- ORDER BY endpoints_check_history.date, ((endpoints_check_history.successful_checks * 100) / health_check_history.total_checks) DESC, (endpoints_check_history.sum_total_time / (health_check_history.total_checks)); diff --git a/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/up.sql b/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/up.sql new file mode 100644 index 00000000..a0ce9a5a --- /dev/null +++ b/hasura/migrations/default/1679498735470_replace_check_history_by_endpoint/up.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE VIEW "public"."check_history_by_endpoint" AS + SELECT endpoints_check_history.producer_id, + endpoints_check_history.value, + endpoints_check_history.date, + health_check_history.total_checks, + (endpoints_check_history.sum_total_time / (health_check_history.total_checks))::real AS avg_time, + ((endpoints_check_history.successful_checks * 100) / health_check_history.total_checks) AS availability + FROM (endpoints_check_history + JOIN health_check_history ON ((endpoints_check_history.date = health_check_history.date))) + ORDER BY endpoints_check_history.date, ((endpoints_check_history.successful_checks * 100) / health_check_history.total_checks) DESC, (endpoints_check_history.sum_total_time / (health_check_history.total_checks)); From 239777a3814c43f00f4b2cf7deb116677086cfdc Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 22 Mar 2023 10:15:59 -0600 Subject: [PATCH 13/20] feat(webapp): add link to endpoints stats in the endpoints list --- webapp/src/components/EndpointsTable/index.js | 45 +++++++++++++------ .../hooks/customHooks/useEndpointsState.js | 1 + .../customHooks/useHealthCheckHistoryState.js | 16 ++++--- .../EndpointsStats/EndpointStatsTable.js | 6 ++- webapp/src/routes/EndpointsStats/index.js | 27 +++++++---- 5 files changed, 67 insertions(+), 28 deletions(-) diff --git a/webapp/src/components/EndpointsTable/index.js b/webapp/src/components/EndpointsTable/index.js index 9e246985..7275258d 100644 --- a/webapp/src/components/EndpointsTable/index.js +++ b/webapp/src/components/EndpointsTable/index.js @@ -11,6 +11,9 @@ import TableRow from '@mui/material/TableRow' import Typography from '@mui/material/Typography' import { Tooltip as MUITooltip } from '@mui/material' import ListAltIcon from '@mui/icons-material/ListAlt' +import { Link as RouterLink } from 'react-router-dom' +import Link from '@mui/material/Link' +import QueryStatsIcon from '@mui/icons-material/QueryStats'; import HealthCheck from '../HealthCheck' import HealthCheckInfo from 'components/HealthCheck/HealthCheckInfo' @@ -42,7 +45,8 @@ const EndpointsTable = ({ producers }) => { const getStatus = (endpoint) => { if (endpoint.response.status === undefined) return - const diffBlockTimems = new Date(endpoint.updated_at) - new Date(endpoint.head_block_time) + const diffBlockTimems = + new Date(endpoint.updated_at) - new Date(endpoint.head_block_time) if (diffBlockTimems <= syncToleranceInterval) { return 'greenLight' @@ -122,23 +126,38 @@ const EndpointsTable = ({ producers }) => { -
- {t('p2p')} - - { - handlePopoverOpen(e.target, 'p2p') - }} - /> - -
-
+
+ {t('p2p')} + + { + handlePopoverOpen(e.target, 'p2p') + }} + /> + +
+ {producers.map((producer, index) => ( - {producer.name} + +
+ {producer.name} + {!!producer.endpoints.api.length + + producer.endpoints.ssl.length && ( + + + + )} +
+
diff --git a/webapp/src/hooks/customHooks/useEndpointsState.js b/webapp/src/hooks/customHooks/useEndpointsState.js index bf9744b2..03059240 100644 --- a/webapp/src/hooks/customHooks/useEndpointsState.js +++ b/webapp/src/hooks/customHooks/useEndpointsState.js @@ -34,6 +34,7 @@ const useEndpointsState = () => { }) return { + id: producer.id, name: producer.bp_json?.org?.candidate_name || producer?.bp_json?.org?.organization_name || diff --git a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js index f5bb7db8..7f34c871 100644 --- a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js +++ b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react' import { useLazyQuery } from '@apollo/client' +import { useLocation } from 'react-router-dom' import { FASTEST_ENDPOINTS_QUERY, @@ -25,11 +26,13 @@ const useHealthCheckState = () => { const [historyData, setHistoryData] = useState() const [statsAverage, setStatsAverage] = useState() const [dates, setDates] = useState() + const location = useLocation() useEffect(() => { const endpointFilter = { _and: [{ type: { _in: ['ssl', 'api'] } }, { value: { _gt: '' } }], } + loadProducers({ variables: { where: { nodes: { endpoints: endpointFilter } }, @@ -49,8 +52,9 @@ const useHealthCheckState = () => { name: producer?.bp_json?.org?.candidate_name, })), ) - setSelected(producers[0]?.id) - }, [producers]) + setSelected(location?.state?.producerId || producers[0]?.id) + window.history.replaceState({}, document.title) + }, [producers, location]) useEffect(() => { if (!selected) return @@ -62,7 +66,8 @@ const useHealthCheckState = () => { if (!history) return const data = history.reduce((aux, curr) => { - const index = aux.findIndex(x => x.name === curr.value) + const index = aux.findIndex((x) => x.name === curr.value) + if (index < 0) { aux.push({ name: curr.value, @@ -80,10 +85,11 @@ const useHealthCheckState = () => { return aux }, []) + setDates(data[0]?.dates || []) setHistoryData(data) setStatsAverage( - data.map(x => ({ + data.map((x) => ({ value: x.name, avg_time: x.avg_time / x.data.length, availability: x.availability / x.data.length, @@ -101,7 +107,7 @@ const useHealthCheckState = () => { dates, loading, loadingHistory, - loadingProducers + loadingProducers, }, { setSelected }, ] diff --git a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js index 686a8e70..a3126dab 100644 --- a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js +++ b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js @@ -12,6 +12,10 @@ import TableRow from '@mui/material/TableRow' const EndpointsTable = ({endpoints, title}) => { const { t } = useTranslation('EndpointsStatsRoute') + const formatPercentage = value => { + return Number.isInteger(value) ? value : value.toFixed(2) + } + return ( <> @@ -30,7 +34,7 @@ const EndpointsTable = ({endpoints, title}) => { {endpoints.map((item, index) => ( {item.value} - {`${item.availability}%`} + {`${formatPercentage(item.availability)}%`} {`${item.avg_time.toFixed(3)} s`} ))} diff --git a/webapp/src/routes/EndpointsStats/index.js b/webapp/src/routes/EndpointsStats/index.js index acf37690..bb84893e 100644 --- a/webapp/src/routes/EndpointsStats/index.js +++ b/webapp/src/routes/EndpointsStats/index.js @@ -8,6 +8,7 @@ import LinearProgress from '@mui/material/LinearProgress' import MenuItem from '@mui/material/MenuItem' import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' +import FormControl from '@mui/material/FormControl' import moment from 'moment' import Select from '@mui/material/Select' import { makeStyles } from '@mui/styles' @@ -67,11 +68,19 @@ const EndpointsStats = () => {
{producersNames?.length && ( - + + + )} {historyData && ( { /> )} {statsAverage && ( - + )}
From b6b0535927fbc9f4bd7c6d5a6a6b962ce1f36d43 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 22 Mar 2023 14:41:09 -0600 Subject: [PATCH 14/20] refactor(webapp): fix sintax error and refactor code --- webapp/src/gql/producer.gql.js | 7 +- .../customHooks/useHealthCheckHistoryState.js | 76 ++++++++++--------- .../EndpointsStats/EndpointStatsTable.js | 12 ++- webapp/src/routes/EndpointsStats/index.js | 3 +- 4 files changed, 56 insertions(+), 42 deletions(-) diff --git a/webapp/src/gql/producer.gql.js b/webapp/src/gql/producer.gql.js index 1e3df9f8..61051251 100644 --- a/webapp/src/gql/producer.gql.js +++ b/webapp/src/gql/producer.gql.js @@ -212,7 +212,7 @@ export const EOSRATE_STATS_QUERY = gql` ` export const FASTEST_ENDPOINTS_QUERY = gql`query($today: date){ - endpoints: check_history_by_endpoint(limit: 5, order_by: {avg_time: asc, availability: desc}, where: {date: {_eq: $today}}) { + endpoints: check_history_by_endpoint(limit: 5, order_by: [{availability: desc, avg_time: asc}], where: {date: {_eq: $today}}) { value avg_time availability @@ -220,12 +220,15 @@ export const FASTEST_ENDPOINTS_QUERY = gql`query($today: date){ }` export const HISTORY_ENDPOINTS_BY_PRODUCER_QUERY = gql`query($id: Int){ - endpoints: check_history_by_endpoint(order_by: {value: asc, date: asc}, where: {producer_id: {_eq: $id}}) { + endpoints: check_history_by_endpoint(order_by: [{value: asc},{date: asc}], where: {producer_id: {_eq: $id}}) { value date avg_time availability } + dates: check_history_by_endpoint(order_by: {date: asc}, where: {producer_id: {_eq: $id}}, distinct_on: [date]) { + date + } }` diff --git a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js index 7f34c871..fdc2e05e 100644 --- a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js +++ b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react' import { useLazyQuery } from '@apollo/client' import { useLocation } from 'react-router-dom' +import moment from 'moment' import { FASTEST_ENDPOINTS_QUERY, @@ -19,13 +20,16 @@ const useHealthCheckState = () => { ] = useLazyQuery(PRODUCERS_QUERY) const [ loadHistory, - { loading: loadingHistory = true, data: { endpoints: history } = {} }, + { + loading: loadingHistory = true, + data: { endpoints: history, dates } = {}, + }, ] = useLazyQuery(HISTORY_ENDPOINTS_BY_PRODUCER_QUERY) const [producersNames, setProducersNames] = useState() const [selected, setSelected] = useState() const [historyData, setHistoryData] = useState() const [statsAverage, setStatsAverage] = useState() - const [dates, setDates] = useState() + const [formattedDates, setFormattedDates] = useState() const location = useLocation() useEffect(() => { @@ -47,7 +51,7 @@ const useHealthCheckState = () => { if (!producers?.length) return setProducersNames( - producers.map((producer) => ({ + producers.map(producer => ({ id: producer.id, name: producer?.bp_json?.org?.candidate_name, })), @@ -65,37 +69,41 @@ const useHealthCheckState = () => { useEffect(() => { if (!history) return - const data = history.reduce((aux, curr) => { - const index = aux.findIndex((x) => x.name === curr.value) - - if (index < 0) { - aux.push({ - name: curr.value, - data: [curr.avg_time], - dates: [curr.date], - avg_time: curr.avg_time, - availability: curr.availability, - }) - } else { - aux[index].data.push(curr.avg_time) - aux[index].availability = aux[index].availability + curr.availability - aux[index].avg_time = aux[index].avg_time + curr.avg_time - aux[index].dates.push(curr.date) - } - - return aux - }, []) - - setDates(data[0]?.dates || []) - setHistoryData(data) - setStatsAverage( - data.map((x) => ({ - value: x.name, - avg_time: x.avg_time / x.data.length, - availability: x.availability / x.data.length, - })), + let previous = '' + + const { data, stats } = history.reduce( + (aux, curr) => { + if (previous !== curr.value) { + aux.data.push({ + name: curr.value, + data: [curr.avg_time], + }) + aux.stats.push({ + value: curr.value, + avg_time: curr.avg_time, + availability: curr.availability, + total: 1, + }) + + previous = curr.value + } else { + const index = aux.data.length - 1 + + aux.data[index].data.push(curr.avg_time) + aux.stats[index].availability += curr.availability + aux.stats[index].avg_time += curr.avg_time + aux.stats[index].total++ + } + + return aux + }, + { data: [], stats: [] }, ) - }, [history]) + + setHistoryData(data) + setStatsAverage(stats) + setFormattedDates(dates.map(item => moment(item.date).format('ll'))) + }, [history, dates]) return [ { @@ -104,7 +112,7 @@ const useHealthCheckState = () => { historyData, statsAverage, selected, - dates, + dates: formattedDates, loading, loadingHistory, loadingProducers, diff --git a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js index a3126dab..7a662bbc 100644 --- a/webapp/src/routes/EndpointsStats/EndpointStatsTable.js +++ b/webapp/src/routes/EndpointsStats/EndpointStatsTable.js @@ -9,10 +9,10 @@ import TableContainer from '@mui/material/TableContainer' import TableHead from '@mui/material/TableHead' import TableRow from '@mui/material/TableRow' -const EndpointsTable = ({endpoints, title}) => { +const EndpointsTable = ({ endpoints, title }) => { const { t } = useTranslation('EndpointsStatsRoute') - const formatPercentage = value => { + const formatValue = value => { return Number.isInteger(value) ? value : value.toFixed(2) } @@ -34,8 +34,12 @@ const EndpointsTable = ({endpoints, title}) => { {endpoints.map((item, index) => ( {item.value} - {`${formatPercentage(item.availability)}%`} - {`${item.avg_time.toFixed(3)} s`} + {`${formatValue( + item.availability / (item?.total || 1), + )}%`} + {`${formatValue( + item.avg_time / (item?.total || 1), + )} s`} ))}
diff --git a/webapp/src/routes/EndpointsStats/index.js b/webapp/src/routes/EndpointsStats/index.js index bb84893e..1847e418 100644 --- a/webapp/src/routes/EndpointsStats/index.js +++ b/webapp/src/routes/EndpointsStats/index.js @@ -9,7 +9,6 @@ import MenuItem from '@mui/material/MenuItem' import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' import FormControl from '@mui/material/FormControl' -import moment from 'moment' import Select from '@mui/material/Select' import { makeStyles } from '@mui/styles' @@ -86,7 +85,7 @@ const EndpointsStats = () => { moment(x).format('ll')), + categories: dates, }, series: historyData }} /> )} From 7ec36036f1e88e5c624d3692cda8d1a3af9ee8e6 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Wed, 22 Mar 2023 16:50:53 -0600 Subject: [PATCH 15/20] refactor(hapi): use flatMap and remove unneeded order by --- hapi/src/services/producer.service.js | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index 3f1c2127..a2217ddc 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -122,7 +122,7 @@ const syncEndpoints = async () => { producers : producer(where: {nodes: {endpoints: {_and: [{value: {_gt: ""}}]}}}, order_by: {rank: asc}) { id nodes { - endpoints(where: {type: {_in: ["api", "ssl"]}}, order_by: {value: asc}) { + endpoints(where: {type: {_in: ["api", "ssl"]}}) { id value type @@ -138,51 +138,55 @@ const syncEndpoints = async () => { } } = await hasuraUtil.request(query) - if (!count) return + if (!count) return let endpoints = await Promise.all( - producers.map(async producer => { + producers.flatMap(async producer => { const endpoints = producer.nodes.flatMap(node => node?.endpoints || []) - const list = await endpointsHealth(endpoints) - return (list.map(endpoint => ({...endpoint,producer_id:producer.id}))) - })) - - endpoints = endpoints.flat() + return await endpointsHealth(endpoints, producer.id) + }) + ) await healthCheckHistoryService.saveHealthRegister(endpoints) } -const endpointsHealth = async endpoints => { +const endpointsHealth = async (endpoints, producer_id) => { const checkedList = [] - for(index in endpoints){ - const endpoint = {...endpoints[index]} - const repeatedIndex = checkedList.findIndex(info => info.value === endpoint.value) + for (index in endpoints) { + const endpoint = { ...endpoints[index] } + const repeatedIndex = checkedList.findIndex( + info => info.value === endpoint.value + ) const isRepeated = repeatedIndex >= 0 - if(isRepeated){ + if (isRepeated) { const previous = checkedList[repeatedIndex] - + endpoint.response = previous.response endpoint.head_block_time = previous.head_block_time endpoint.updated_at = previous.updated_at - }else{ + } else { const startTime = new Date() - const {nodeInfo, ...response} = await producerUtil.getNodeInfo( + const { nodeInfo, ...response } = await producerUtil.getNodeInfo( endpoint.value ) endpoint.time = (new Date() - startTime) / 1000 - endpoint.response = response + endpoint.response = response endpoint.head_block_time = nodeInfo?.head_block_time || null endpoint.updated_at = new Date() } await nodeService.updateEndpointInfo(endpoint) - if(!isRepeated){ - checkedList.push({...endpoint,isWorking: Number(endpoint?.response?.status === StatusCodes.OK)}) + if (!isRepeated) { + checkedList.push({ + ...endpoint, + producer_id, + isWorking: Number(endpoint?.response?.status === StatusCodes.OK) + }) } } From 97e97478884b5f7e5b4d77ccc23c3f9ab5183606 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Thu, 23 Mar 2023 10:10:37 -0600 Subject: [PATCH 16/20] feat(hapi): fix flatMap --- hapi/src/services/producer.service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index a2217ddc..a20e27bb 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -141,14 +141,14 @@ const syncEndpoints = async () => { if (!count) return let endpoints = await Promise.all( - producers.flatMap(async producer => { + producers.map(async producer => { const endpoints = producer.nodes.flatMap(node => node?.endpoints || []) return await endpointsHealth(endpoints, producer.id) }) ) - await healthCheckHistoryService.saveHealthRegister(endpoints) + await healthCheckHistoryService.saveHealthRegister(endpoints.flat()) } const endpointsHealth = async (endpoints, producer_id) => { From be5aa7318e466326e77070a3232ca8f6e377ab00 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Thu, 23 Mar 2023 10:37:09 -0600 Subject: [PATCH 17/20] feat(webapp): use Autocomplete component --- .../customHooks/useHealthCheckHistoryState.js | 14 ++- webapp/src/language/en.json | 1 + webapp/src/language/es.json | 1 + webapp/src/routes/EndpointsStats/index.js | 90 +++++++++++-------- webapp/src/routes/EndpointsStats/styles.js | 3 + 5 files changed, 70 insertions(+), 39 deletions(-) diff --git a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js index fdc2e05e..4fc069e8 100644 --- a/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js +++ b/webapp/src/hooks/customHooks/useHealthCheckHistoryState.js @@ -27,6 +27,7 @@ const useHealthCheckState = () => { ] = useLazyQuery(HISTORY_ENDPOINTS_BY_PRODUCER_QUERY) const [producersNames, setProducersNames] = useState() const [selected, setSelected] = useState() + const [selectedName, setSelectedName] = useState() const [historyData, setHistoryData] = useState() const [statsAverage, setStatsAverage] = useState() const [formattedDates, setFormattedDates] = useState() @@ -56,7 +57,13 @@ const useHealthCheckState = () => { name: producer?.bp_json?.org?.candidate_name, })), ) - setSelected(location?.state?.producerId || producers[0]?.id) + + const id = location?.state?.producerId + const producer = + producers.find(producer => producer.id === id) || producers[0] + + setSelected(id || producers[0]?.id) + setSelectedName(producer?.bp_json?.org?.candidate_name) window.history.replaceState({}, document.title) }, [producers, location]) @@ -87,7 +94,7 @@ const useHealthCheckState = () => { previous = curr.value } else { - const index = aux.data.length - 1 + const index = aux.data.length - 1 aux.data[index].data.push(curr.avg_time) aux.stats[index].availability += curr.availability @@ -112,12 +119,13 @@ const useHealthCheckState = () => { historyData, statsAverage, selected, + selectedName, dates: formattedDates, loading, loadingHistory, loadingProducers, }, - { setSelected }, + { setSelected, setSelectedName }, ] } diff --git a/webapp/src/language/en.json b/webapp/src/language/en.json index 186928f5..3d5a9cb5 100644 --- a/webapp/src/language/en.json +++ b/webapp/src/language/en.json @@ -394,6 +394,7 @@ "byProducer": "Endpoints stats by producer", "avgAvailability": "Average Availability", "avgTime": "Average Response Time", + "charTitle": "Average Response Time from Costa Rica", "list": "List of endpoints", "timeInSecs": "Time in seconds" } diff --git a/webapp/src/language/es.json b/webapp/src/language/es.json index a47b25a7..e2e19b66 100644 --- a/webapp/src/language/es.json +++ b/webapp/src/language/es.json @@ -411,6 +411,7 @@ "byProducer": "Estadísticas de puntos finales por productor", "avgAvailability": "Disponibilidad promedio", "avgTime": "Tiempo de respuesta promedio", + "charTitle": "Tiempo de respuesta promedio desde Costa Rica", "list": "Lista de puntos finales", "timeInSecs": "Tiempo en segundos" } diff --git a/webapp/src/routes/EndpointsStats/index.js b/webapp/src/routes/EndpointsStats/index.js index 1847e418..9bac286d 100644 --- a/webapp/src/routes/EndpointsStats/index.js +++ b/webapp/src/routes/EndpointsStats/index.js @@ -1,16 +1,15 @@ /* eslint camelcase: 0 */ import React from 'react' +import { makeStyles } from '@mui/styles' import { useTranslation } from 'react-i18next' +import Autocomplete from '@mui/material/Autocomplete' import Card from '@mui/material/Card' import CardContent from '@mui/material/CardContent' -import Typography from '@mui/material/Typography' -import LinearProgress from '@mui/material/LinearProgress' -import MenuItem from '@mui/material/MenuItem' import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' -import FormControl from '@mui/material/FormControl' -import Select from '@mui/material/Select' -import { makeStyles } from '@mui/styles' +import LinearProgress from '@mui/material/LinearProgress' +import TextField from '@mui/material/TextField' +import Typography from '@mui/material/Typography' import useHealthCheckState from '../../hooks/customHooks/useHealthCheckHistoryState' @@ -22,7 +21,18 @@ const useStyles = makeStyles(styles) const EndpointsStats = () => { const { t } = useTranslation('EndpointsStatsRoute') const classes = useStyles() - const [{fastestEndpoints,producersNames,historyData,dates,statsAverage,selected,loading},{setSelected}] = useHealthCheckState() + const [ + { + fastestEndpoints, + producersNames, + historyData, + dates, + statsAverage, + selectedName, + loading, + }, + { setSelected, setSelectedName }, + ] = useHealthCheckState() const options = { xAxis: { @@ -32,7 +42,7 @@ const EndpointsStats = () => { enabled: false, }, title: { - text: t('avgTime'), + text: t('charTitle'), }, yAxis: { title: { @@ -53,10 +63,10 @@ const EndpointsStats = () => { {loading && } {!loading && ( - + )} @@ -65,35 +75,43 @@ const EndpointsStats = () => { {t('byProducer')} -
{producersNames?.length && ( - - - + producer.name)} + value={selectedName} + onChange={(_event, newValue) => { + const producer = producersNames.find( + producer => producer.name === newValue, + ) + + if (!producer) return + + setSelected(producer.id) + }} + inputValue={selectedName} + onInputChange={(_event, newInputValue) => { + setSelectedName(newInputValue) + }} + renderInput={params => ( + + )} + /> )} {historyData && ( - + )} {statsAverage && ( - + )} diff --git a/webapp/src/routes/EndpointsStats/styles.js b/webapp/src/routes/EndpointsStats/styles.js index 342f4ff9..d36ef0ed 100644 --- a/webapp/src/routes/EndpointsStats/styles.js +++ b/webapp/src/routes/EndpointsStats/styles.js @@ -4,5 +4,8 @@ export default (theme) => ({ }, cardByProducer: { marginTop: theme.spacing(8) + }, + select: { + margin: `${theme.spacing(8)} ${theme.spacing(2)}` } }) From a9057f1dcce38345a74edccdb169fe6a87941660 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 23 Mar 2023 17:30:03 +0000 Subject: [PATCH 18/20] [CodeFactor] Apply fixes --- hapi/src/services/producer.service.js | 20 ++++++++++---------- webapp/src/gql/producer.gql.js | 2 -- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index a20e27bb..e3761788 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -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() @@ -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 @@ -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) @@ -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) }) @@ -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 @@ -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 } }] diff --git a/webapp/src/gql/producer.gql.js b/webapp/src/gql/producer.gql.js index 61051251..c295daf3 100644 --- a/webapp/src/gql/producer.gql.js +++ b/webapp/src/gql/producer.gql.js @@ -230,5 +230,3 @@ export const HISTORY_ENDPOINTS_BY_PRODUCER_QUERY = gql`query($id: Int){ date } }` - - From 5757924f43f457c5496a6255702efcab7de06e8b Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Thu, 23 Mar 2023 11:32:12 -0600 Subject: [PATCH 19/20] fix(hapi): apply fixes in not defined --- hapi/src/services/health-check-history.service.js | 2 +- hapi/src/services/producer.service.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hapi/src/services/health-check-history.service.js b/hapi/src/services/health-check-history.service.js index be393e07..b8985e6c 100644 --- a/hapi/src/services/health-check-history.service.js +++ b/hapi/src/services/health-check-history.service.js @@ -34,7 +34,7 @@ const updateEndpointsHealthHistory = async (endpoints, date) => { } } ` - updates = endpoints.map(endpoint => ({ + const updates = endpoints.map(endpoint => ({ where: { _and: [{ value: { _eq: endpoint.value } }, { date: { _eq: date } }] }, diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index e3761788..c1b1da16 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -154,7 +154,7 @@ const syncEndpoints = async () => { const endpointsHealth = async (endpoints, producer_id) => { const checkedList = [] - for (index in endpoints) { + for (let index in endpoints) { const endpoint = { ...endpoints[index] } const repeatedIndex = checkedList.findIndex( (info) => info.value === endpoint.value From b74a61f8561ce7fa85dec76a476e3b7cc0318493 Mon Sep 17 00:00:00 2001 From: Torresmorah Date: Thu, 23 Mar 2023 11:34:44 -0600 Subject: [PATCH 20/20] fix(hapi): apply fixes in wrong format --- hapi/src/services/producer.service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hapi/src/services/producer.service.js b/hapi/src/services/producer.service.js index c1b1da16..5387420c 100644 --- a/hapi/src/services/producer.service.js +++ b/hapi/src/services/producer.service.js @@ -151,10 +151,10 @@ const syncEndpoints = async () => { await healthCheckHistoryService.saveHealthRegister(endpoints.flat()) } -const endpointsHealth = async (endpoints, producer_id) => { +const endpointsHealth = async (endpoints, producerId) => { const checkedList = [] - for (let index in endpoints) { + for (const index in endpoints) { const endpoint = { ...endpoints[index] } const repeatedIndex = checkedList.findIndex( (info) => info.value === endpoint.value @@ -184,7 +184,7 @@ const endpointsHealth = async (endpoints, producer_id) => { if (!isRepeated) { checkedList.push({ ...endpoint, - producer_id, + producer_id: producerId, isWorking: Number(endpoint?.response?.status === StatusCodes.OK) }) }