-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explore apps statistics component - Closes #4358 #4370
Add explore apps statistics component - Closes #4358 #4370
Conversation
* | ||
* @returns {Promise} | ||
*/ | ||
export const getStatistics = () => Promise.resolve({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the end point and make the api call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed to mock it and API call is not ready. It should be done after this ticket. LiskArchive/lisk-service#1113
I suggest creating a ticket to unmock the api call (Which is written but comented)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the api call here but inside the component use the mock not the api response check @eniolam1000752 pr
datasets: [ | ||
{ | ||
backgroundColor: [colorPalette[1], colorPalette[0], colorPalette[2]], | ||
data: apps.data.reduce((acc, stats) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? the api response it will give us the data
{
"data": {
"registered": 2503,
"active": 2328,
"terminated": 35,
“totalSupplyLSK”: “5000000”,
“stakedLSK”: “3000000”,
“inflationRate”: “4.50”,
},
"meta": {},
"links": {}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 callls, 1 for apps list and other for apps. We have to iterate the apps list to get the status and generate the status map. As far as I understood
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please go over the end point and check it one more time,
api is providing the application count based on the status
"registered": 2503, "active": 2328, "terminated": 35,
import React from 'react'; | ||
import BlockchainApplicationStatistics from '../../../explore/components/BlockchainApplicationStatistics'; | ||
|
||
const ManageBlockchainAppications = ({ apps, statistics }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please improve naming apps is so general, also it dosnt need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How I should rename it?
…into 4358-explore-apps-statistics
* | ||
* @returns {Promise} | ||
*/ | ||
export const getApps = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused apps
@@ -0,0 +1,49 @@ | |||
/* istanbul ignore file */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file should be go to /blockchainApplication/explore/api
@@ -0,0 +1,25 @@ | |||
/* istanbul ignore file */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the component file from index to BlockchainApplicationStatistics
const doughnutChartData = { | ||
labels: [ | ||
t('Registered'), | ||
t('Active'), | ||
t('Terminated'), | ||
], | ||
datasets: [ | ||
{ | ||
backgroundColor: [colorPalette[1], colorPalette[0], colorPalette[2]], | ||
data: [statistics.data.registered, statistics.data.active, statistics.data.terminated], | ||
}, | ||
], | ||
}; | ||
|
||
const doughnutChartOptions = { | ||
cutoutPercentage: 70, | ||
legend: { | ||
display: true, | ||
position: 'left', | ||
align: 'start', | ||
labels: { | ||
padding: 20, | ||
}, | ||
}, | ||
layout: { | ||
padding: { | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
top: 0, | ||
}, | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the part to utils and keep the component clean
const doughnutChartData = { | |
labels: [ | |
t('Registered'), | |
t('Active'), | |
t('Terminated'), | |
], | |
datasets: [ | |
{ | |
backgroundColor: [colorPalette[1], colorPalette[0], colorPalette[2]], | |
data: [statistics.data.registered, statistics.data.active, statistics.data.terminated], | |
}, | |
], | |
}; | |
const doughnutChartOptions = { | |
cutoutPercentage: 70, | |
legend: { | |
display: true, | |
position: 'left', | |
align: 'start', | |
labels: { | |
padding: 20, | |
}, | |
}, | |
layout: { | |
padding: { | |
left: 0, | |
right: 0, | |
bottom: 0, | |
top: 0, | |
}, | |
}, | |
}; | |
const {doughnutChartData, doughnutChartOptions} = prepareChartDataAndOptions(data, colorPalette) |
src/modules/blockchainApplication/explore/components/BlockchainApplicationStatistics/index.js
Outdated
Show resolved
Hide resolved
<p className={`${styles.statsInfo} stacked-token`}> | ||
<TokenAmount | ||
val={toRawLsk(statistics.data.stakedLSK)} | ||
token={tokenMap.LSK.key} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the LSK map here they are deprecated and non-related to here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then how we pass the token? If we don't pass token it will display '5,000,000' instead of '5,000,000 LSK(or other token)' as it is in design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just prefer to use a constant for those things, but now tokenMap is fine
Please Resolve merge conflicts :) |
/* istanbul ignore file */ | ||
import http from 'src/utils/api/http'; | ||
import { HTTP_PREFIX } from 'src/const/httpCodes'; | ||
|
||
const httpPaths = { | ||
blockchainAppsStatistics: `${HTTP_PREFIX}/blockchain/apps/statistics`, | ||
}; | ||
|
||
/** | ||
* Retrieves sidechains statistics information | ||
* | ||
* @param {Object} data | ||
* @param {Object} data.network The network config from the Redux store | ||
* | ||
* @returns {Promise} | ||
*/ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const getStatistics = ({ | ||
network, | ||
params = {}, | ||
baseUrl, | ||
}) => http({ | ||
path: httpPaths.blockchainAppsStatistics, | ||
network, | ||
params, | ||
baseUrl, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a unit test
|
||
expect(wrapper.find('TokenAmount').at(0)).toHaveText('5,000,000'); | ||
expect(wrapper.find('TokenAmount').at(1)).toHaveText('3,000,000'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,38 @@ | |||
// eslint-disable-next-line import/prefer-default-export | |||
export const prepareChartDataAndOptions = (statistics, colorPalette, t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can have a unit test for this function
const baseUrl = 'http://custom-base-url.com/'; | ||
const { network } = getState(); | ||
|
||
describe('get blockchain application detail', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
describe('get blockchain application detail', () => { | |
describe('get blockchain application statistics', () => { |
<> | ||
<BlockchainApplicationStatistics apps={apps} statistics={statistics} /> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a need for fragments(<>
) here
@@ -0,0 +1,38 @@ | |||
// eslint-disable-next-line import/prefer-default-export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have the file name equal to the function so its easier to find it,
* Add component and screen structure * Add tooltips * Create api util * Add TODO dependency on api call * Add unit test * Add icons * Adjust styles * Fix lint * Adjust chart styles and options * Add coverage expections * Increase e2e wait time * Add alias * remove old routesMap * PR feedback * Update unit test * PR feedback * Fix test and lint * Add unit tests * Ignore branch coverage * Lint issues * PR feedback
* Add component and screen structure * Add tooltips * Create api util * Add TODO dependency on api call * Add unit test * Add icons * Adjust styles * Fix lint * Adjust chart styles and options * Add coverage expections * Increase e2e wait time * Add alias * remove old routesMap * PR feedback * Update unit test * PR feedback * Fix test and lint * Add unit tests * Ignore branch coverage * Lint issues * PR feedback
What was the problem?
This PR resolves #4358
How was it solved?
How was it tested?
Add unit test