From a3089eb06e5ad28c2ea1a85a22bcf4d3fd3ff651 Mon Sep 17 00:00:00 2001 From: Keith Date: Sun, 1 Oct 2023 01:48:20 +0800 Subject: [PATCH 1/2] chore: remove unused dep --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index cf86bc266..2e7f37db7 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "@types/react-router-dom": "5.3.3", "@types/react-test-renderer": "^18.0.0", "@types/styled-components": "5.1.26", - "@types/three": "0.149.0", "@typescript-eslint/eslint-plugin": "^4.29.0", "@typescript-eslint/parser": "5.62.0", "antd-dayjs-webpack-plugin": "^1.0.6", From 2680651bc73d29f9cccf04e8945f247cb334fc0f Mon Sep 17 00:00:00 2001 From: Keith Date: Sat, 7 Oct 2023 00:58:28 +0700 Subject: [PATCH 2/2] fix: filter latest data point from chart if it's exceptional --- src/service/http/fetcher.ts | 88 +++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/src/service/http/fetcher.ts b/src/service/http/fetcher.ts index 0606c8d74..c4abf81b7 100644 --- a/src/service/http/fetcher.ts +++ b/src/service/http/fetcher.ts @@ -210,14 +210,24 @@ export const fetchNervosDaoDepositors = () => ) export const fetchStatisticTransactionCount = () => - axiosIns(`/daily_statistics/transactions_count`).then((res: AxiosResponse) => - toCamelcase[]>>(res.data), - ) + axiosIns(`/daily_statistics/transactions_count`).then((res: AxiosResponse) => { + const resp = toCamelcase[]>>(res.data) + return { + ...resp, + // filter latest exceptional data out + data: resp.data.filter((item, idx) => idx < resp.data.length - 2 || item.attributes.transactionsCount !== '0'), + } + }) export const fetchStatisticAddressCount = () => - axiosIns(`/daily_statistics/addresses_count`).then((res: AxiosResponse) => - toCamelcase[]>>(res.data), - ) + axiosIns(`/daily_statistics/addresses_count`).then((res: AxiosResponse) => { + const resp = toCamelcase[]>>(res.data) + return { + ...resp, + // filter latest exceptional data out + data: resp.data.filter((item, idx) => idx < resp.data.length - 2 || item.attributes.addressesCount !== '0'), + } + }) export const fetchStatisticTotalDaoDeposit = () => axiosIns(`/daily_statistics/total_depositors_count-total_dao_deposit`).then((res: AxiosResponse) => @@ -244,35 +254,46 @@ export const fetchStatisticDifficultyHashRate = () => const resp = toCamelcase[]>>(res.data) return { ...resp, - data: resp.data.map(wrapper => ({ - ...wrapper, - attributes: { - // Data may enter the cache, so it is purify to reduce volume. - ...pick(wrapper.attributes, ['difficulty', 'epochNumber']), - uncleRate: new BigNumber(wrapper.attributes.uncleRate).toFixed(4), - hashRate: new BigNumber(wrapper.attributes.hashRate).multipliedBy(1000).toString(), - }, - })), + data: resp.data + // filter latest exceptional data out + .filter((item, idx) => idx < resp.data.length - 2 || item.attributes.hashRate !== '0.0') + .map(wrapper => ({ + ...wrapper, + attributes: { + // Data may enter the cache, so it is purify to reduce volume. + ...pick(wrapper.attributes, ['difficulty', 'epochNumber']), + uncleRate: new BigNumber(wrapper.attributes.uncleRate).toFixed(4), + hashRate: new BigNumber(wrapper.attributes.hashRate).multipliedBy(1000).toString(), + }, + })), } }) export const fetchStatisticDifficulty = () => - axiosIns(`/daily_statistics/avg_difficulty`).then((res: AxiosResponse) => - toCamelcase[]>>(res.data), - ) + axiosIns(`/daily_statistics/avg_difficulty`).then((res: AxiosResponse) => { + const resp = toCamelcase[]>>(res.data) + return { + ...resp, + // filter latest exceptional data out + data: resp.data.filter((item, idx) => idx < resp.data.length - 2 || item.attributes.avgDifficulty !== '0.0'), + } + }) export const fetchStatisticHashRate = () => axiosIns(`/daily_statistics/avg_hash_rate`).then((res: AxiosResponse) => { const resp = toCamelcase[]>>(res.data) return { ...resp, - data: resp.data.map(wrapper => ({ - ...wrapper, - attributes: { - ...wrapper.attributes, - avgHashRate: new BigNumber(wrapper.attributes.avgHashRate).multipliedBy(1000).toString(), - }, - })), + data: resp.data + // filter latest exceptional data out + .filter((item, idx) => idx < resp.data.length - 2 || item.attributes.avgHashRate !== '0.0') + .map(wrapper => ({ + ...wrapper, + attributes: { + ...wrapper.attributes, + avgHashRate: new BigNumber(wrapper.attributes.avgHashRate).multipliedBy(1000).toString(), + }, + })), } }) @@ -281,13 +302,16 @@ export const fetchStatisticUncleRate = () => const resp = toCamelcase[]>>(res.data) return { ...resp, - data: resp.data.map(wrapper => ({ - ...wrapper, - attributes: { - ...wrapper.attributes, - uncleRate: new BigNumber(wrapper.attributes.uncleRate).toFixed(4), - }, - })), + data: resp.data + // filter latest exceptional data out + .filter((item, idx) => idx < resp.data.length - 2 || item.attributes.uncleRate !== '0') + .map(wrapper => ({ + ...wrapper, + attributes: { + ...wrapper.attributes, + uncleRate: new BigNumber(wrapper.attributes.uncleRate).toFixed(4), + }, + })), } })