Skip to content
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

BE-415 | remove duplicate peerStatus api call #416

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions client/src/components/Header/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
getChangeChannelType,
getDashStatsType,
getPeerListType,
getPeerStatusType,
getTransactionByOrgType,
getTransactionPerHourType,
getTransactionPerMinType,
Expand All @@ -66,7 +65,6 @@ const {
dashStats,
changeChannel,
blockActivity,
peerStatus
} = chartOperations;

const {
Expand Down Expand Up @@ -460,7 +458,6 @@ export class HeaderView extends Component {
getChannels,
getDashStats,
getPeerList,
getPeerStatus,
getTransactionByOrg,
getTransactionList,
getTransactionListSearch,
Expand All @@ -480,7 +477,6 @@ export class HeaderView extends Component {
getDashStats(currentChannel),
getBlockActivity(currentChannel),
getPeerList(currentChannel),
getPeerStatus(currentChannel),
getTransactionByOrg(currentChannel),
getTransactionListSearch(currentChannel,transactionListSearchQuery,transactionListSearchPageParam),
getTransactionPerHour(currentChannel),
Expand Down Expand Up @@ -682,7 +678,6 @@ HeaderView.propTypes = {
getChannels: getChannelsType.isRequired,
getDashStats: getDashStatsType.isRequired,
getPeerList: getPeerListType.isRequired,
getPeerStatus: getPeerStatusType.isRequired,
getTransactionByOrg: getTransactionByOrgType.isRequired,
getTransactionPerHour: getTransactionPerHourType.isRequired,
getTransactionPerMin: getTransactionPerMinType.isRequired,
Expand Down Expand Up @@ -712,7 +707,6 @@ const mapDispatchToProps = {
getChannels: channels,
getDashStats: dashStats,
getPeerList: peerList,
getPeerStatus: peerStatus,
getBlockActivity: blockActivity,
getTransactionByOrg: transactionByOrg,
getTransactionList: transactionList,
Expand Down
1 change: 0 additions & 1 deletion client/src/components/Header/HeaderView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const setup = prop => {
getDashStats: jest.fn(),
getNotification: jest.fn(),
getPeerList: jest.fn(),
getPeerStatus: jest.fn(),
getBlockActivity: jest.fn(),
getTransactionByOrg: jest.fn(),
getTransactionList: jest.fn(),
Expand Down
7 changes: 1 addition & 6 deletions client/src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
peerListType,
txnListType,
blockSearchType,
peerStatusType,
blockRangeSearchType,
blockListSearchType,
chaincodeMetaDataType,
Expand All @@ -41,7 +40,6 @@ const {
blockActivitySelector,
channelListSelector,
dashStatsSelector,
peerStatusSelector,
transactionByOrgSelector
} = chartSelectors;

Expand Down Expand Up @@ -89,7 +87,6 @@ export const Main = props => {
peerList,
txnList,
blockSearch,
peerStatus,
chaincodeMetaData,
getChaincodeMetaData,
transaction,
Expand Down Expand Up @@ -142,7 +139,7 @@ export const Main = props => {
const dashboardViewProps = {
blockListSearch,
dashStats,
peerStatus,
peerList,
txnList,
blockSearch,
transactionByOrg,
Expand Down Expand Up @@ -258,7 +255,6 @@ Main.propTypes = {
peerList: peerListType.isRequired,
txnList: txnListType.isRequired,
blockSearch: blockSearchType.isRequired,
peerStatus: peerStatusType.isRequired,
chaincodeMetaData: chaincodeMetaDataType.isRequired,
transaction: transactionType.isRequired,
transactionByOrg: transactionByOrgType.isRequired,
Expand All @@ -275,7 +271,6 @@ const connectedComponent = connect(
peerList: peerListSelector(state),
txnList: txnListSelector(state),
blockSearch: blockSearchSelector(state),
peerStatus: peerStatusSelector(state),
chaincodeMetaData: chaincodeMetaDataSelector(state),
transaction: transactionSelector(state),
transactionByOrg: transactionByOrgSelector(state),
Expand Down
12 changes: 6 additions & 6 deletions client/src/components/View/DashboardView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import OrgPieChart from '../Charts/OrgPieChart';
import {
blockListSearchType,
dashStatsType,
peerStatusType,
peerListType,
txnListType,
blockSearchType,
transactionByOrgType
Expand Down Expand Up @@ -124,14 +124,14 @@ export class DashboardView extends Component {
const {
blockListSearch,
dashStats,
peerStatus,
peerList,
transactionByOrg,
blockActivity
} = this.props;
if (
blockListSearch === undefined ||
dashStats === undefined ||
peerStatus === undefined ||
peerList === undefined ||
blockActivity === undefined ||
transactionByOrg === undefined
) {
Expand Down Expand Up @@ -170,7 +170,7 @@ export class DashboardView extends Component {
};

render() {
const { dashStats, peerStatus, txnList, blockSearch, blockActivity, transactionByOrg } = this.props;
const { dashStats, peerList, txnList, blockSearch, blockActivity, transactionByOrg } = this.props;
const { hasDbError, notifications } = this.state;
var searchError = ''
if(typeof txnList==='string'){searchError='Txn not found'; }
Expand Down Expand Up @@ -265,7 +265,7 @@ export class DashboardView extends Component {
<Row>
<Col sm="6">
<Card className={classes.section}>
<PeersHealth peerStatus={peerStatus} />
<PeersHealth peerStatus={peerList} />
</Card>
<Card className={classes.section}>
<TimelineStream
Expand Down Expand Up @@ -294,7 +294,7 @@ export class DashboardView extends Component {
DashboardView.propTypes = {
blockListSearch: blockListSearchType.isRequired,
dashStats: dashStatsType.isRequired,
peerStatus: peerStatusType.isRequired,
peerList: peerListType.isRequired,
txnList: txnListType.isRequired,
blockSearch: blockSearchType.isRequired,
transactionByOrg: transactionByOrgType.isRequired
Expand Down
6 changes: 0 additions & 6 deletions client/src/components/View/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
getChannelsType,
getDashStatsType,
getPeerListType,
getPeerStatusType,
getTransactionByOrgType,
getTransactionListType,
getTransactionPerHourType,
Expand All @@ -36,7 +35,6 @@ const {
channel,
channelList,
dashStats,
peerStatus,
transactionByOrg,
transactionPerHour,
transactionPerMin /* ,
Expand Down Expand Up @@ -119,7 +117,6 @@ export class LandingPage extends Component {
getChannels,
getDashStats,
getPeerList,
getPeerStatus,
getBlockActivity,
getTransactionByOrg,
getTransactionList,
Expand Down Expand Up @@ -151,7 +148,6 @@ export class LandingPage extends Component {
getChannels(),
getDashStats(currentChannel),
getPeerList(currentChannel),
getPeerStatus(currentChannel),
getBlockActivity(currentChannel),
getTransactionByOrg(currentChannel),
getTransactionListSearch(currentChannel,query,pageParams),
Expand Down Expand Up @@ -215,7 +211,6 @@ LandingPage.propTypes = {
getChannels: getChannelsType.isRequired,
getDashStats: getDashStatsType.isRequired,
getPeerList: getPeerListType.isRequired,
getPeerStatus: getPeerStatusType.isRequired,
getTransactionByOrg: getTransactionByOrgType.isRequired,
getTransactionList: getTransactionListType.isRequired,
getTransactionPerHour: getTransactionPerHourType.isRequired,
Expand Down Expand Up @@ -247,7 +242,6 @@ const mapDispatchToProps = {
getChannels: channels,
getDashStats: dashStats,
getPeerList: peerList,
getPeerStatus: peerStatus,
getBlockActivity: blockActivity,
getTransactionByOrg: transactionByOrg,
getTransactionListSearch: transactionListSearch,
Expand Down
5 changes: 0 additions & 5 deletions client/src/state/redux/charts/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ const getNotification = notification => ({
payload: { notification },
});

const getPeerStatus = peerStatus => ({
type: types.PEER_STATUS,
payload: peerStatus,
});
const getBlockActivity = blocks => ({
type: types.BLOCK_ACTIVITY,
payload: blocks,
Expand Down Expand Up @@ -73,7 +69,6 @@ export default {
getChannelList,
getDashStats,
getNotification,
getPeerStatus,
getTransactionByOrg,
getTransactionPerHour,
getTransactionPerMin,
Expand Down
20 changes: 0 additions & 20 deletions client/src/state/redux/charts/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,6 @@ const notification = notificationObj => dispatch => {
dispatch(actions.getNotification(notify));
};

/* istanbul ignore next */
const peerStatus = channelName => dispatch =>
get(`/api/peersStatus/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
actions.getErroMessage(
'500 Internal Server Error: The server has encountered an internal error and unable to complete your request'
)
);
} else if (resp.status === 400) {
dispatch(actions.getErroMessage(resp.error));
} else {
dispatch(actions.getPeerStatus(resp));
}
})
.catch(error => {
console.error(error);
});

/* istanbul ignore next */
const transactionByOrg = channelName => dispatch =>
Expand Down Expand Up @@ -242,6 +223,5 @@ export default {
channel,
channelList,
changeChannel,
peerStatus,
blockActivity
};
12 changes: 0 additions & 12 deletions client/src/state/redux/charts/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,6 @@ const notificationReducer = (state = initialState, action = {}) => {
}
};

const peerStatusReducer = (state = initialState, action = {}) => {
if (action.type === types.PEER_STATUS) {
return {
list: action.payload.peers,
loaded: true,
errors: action.errors,
};
} else {
return state;
}
};

const transactionByOrgReducer = (state = initialState, action = {}) => {
if (action.type === types.TRANSACTION_CHART_ORG) {
Expand Down Expand Up @@ -142,7 +131,6 @@ const reducer = combineReducers({
channelList: channelListReducer,
dashStats: dashStatsReducer,
notification: notificationReducer,
peerStatus: peerStatusReducer,
transactionByOrg: transactionByOrgReducer,
transactionPerHour: transactionPerHourReducer,
transactionPerMin: transactionPerMinReducer,
Expand Down
1 change: 0 additions & 1 deletion client/src/state/redux/charts/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const channelListSelector = state => state.charts.channelList.list;
export const currentChannelSelector = state => state.charts.channel.currentChannel;
export const dashStatsSelector = state => state.charts.dashStats;
export const notificationSelector = state => state.charts.notification;
export const peerStatusSelector = state => state.charts.peerStatus.list;
export const transactionByOrgSelector = state => state.charts.transactionByOrg.rows;
export const transactionPerHourSelector = state => state.charts.transactionPerHour.rows;
export const transactionPerMinSelector = state => state.charts.transactionPerMin.rows;
Expand Down
43 changes: 0 additions & 43 deletions client/src/state/redux/charts/tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,37 +218,6 @@ describe('Charts', () => {
expect(actions[0].type).toBe(types.NOTIFICATION_LOAD);
});

test('peerStatus', () => {
nock(/\w*(\W)/g)
.get(`/api/peersStatus/${channel}`)
.reply(200, {
rows: [{ test: 'rows' }]
});

const expectedActions = [{ type: types.PEER_STATUS }];
const store = mockStore(initialState, expectedActions);

return store.dispatch(operations.peerStatus(channel)).then(() => {
const actions = store.getActions();
expect(actions[0].type).toBe(types.PEER_STATUS);
});
});

test('peerStatus catch error', () => {
jest.spyOn(console, 'error');
nock(/\w*(\W)/g)
.get(`/api/peersStatus/${channel}`)
.replyWithError({ code: 'ECONNREFUSED' });

const expectedActions = [{ type: types.peerStatus }];
const store = mockStore(initialState, expectedActions);

return store.dispatch(operations.peerStatus(channel)).then(() => {
const actions = store.getActions();
expect(actions).toEqual([]);
});
});

test('transactionByOrg', () => {
nock(/\w*(\W)/g)
.get(`/api/txByOrg/${channel}`)
Expand Down Expand Up @@ -433,13 +402,6 @@ describe('Charts', () => {
expect(newState.notification).toBe('test');
});

test('peerStatusReducer', () => {
const payload = { peers: 'test' };
const action = actions.getPeerStatus(payload);

const newState = reducers(initialState, action);
expect(newState.peerStatus.list).toBe('test');
});

test('transactionByOrgReducer', () => {
const payload = { rows: 'test' };
Expand Down Expand Up @@ -520,11 +482,6 @@ describe('Charts', () => {
expect(notification).toBe('test');
});

test('peerStatusSelector', () => {
const state = { charts: { peerStatus: { list: 'test' } } };
const peerStatus = selectors.peerStatusSelector(state);
expect(peerStatus).toBe('test');
});

test('transactionByOrgSelector', () => {
const state = { charts: { transactionByOrg: { rows: 'test' } } };
Expand Down
2 changes: 0 additions & 2 deletions client/src/state/redux/charts/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const CHANNEL = `${namespaces}/CHANNEL`;
const CHANGE_CHANNEL = `${namespaces}/CHANGE_CHANNEL`;
const CHANNEL_LIST = `${namespaces}/CHANNEL_LIST`;

const PEER_STATUS = `${namespaces}/PEER_STATUS`;

const ERROR_MESSAGE = 'ERROR_MESSAGE';

Expand All @@ -37,7 +36,6 @@ export default {
CHANNEL_LIST,
DASHBOARD_STATS,
NOTIFICATION_LOAD,
PEER_STATUS,
TRANSACTION_CHART_HOUR,
TRANSACTION_CHART_MIN,
TRANSACTION_CHART_ORG,
Expand Down