fix(governance): add enactment date to proposal sorting (#3875)

This commit is contained in:
Sam Keen 2023-05-23 16:53:01 +01:00 committed by GitHub
parent c2baaa2dd9
commit 1d3298cdc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 32 deletions

View File

@ -115,29 +115,6 @@ describe('Proposals list', () => {
);
});
it('Orders proposals correctly by closingDateTime', () => {
render(
renderComponent([
failedProposalClosedLastMonth,
openProposalClosesNextMonth,
openProposalClosesNextWeek,
enactedProposalClosedLastWeek,
])
);
const openProposals = within(screen.getByTestId('open-proposals'));
const closedProposals = within(screen.getByTestId('closed-proposals'));
const openProposalsItems = openProposals.getAllByTestId(
'proposals-list-item'
);
const closedProposalsItems = closedProposals.getAllByTestId(
'proposals-list-item'
);
expect(openProposalsItems[0]).toHaveAttribute('id', 'proposal2');
expect(openProposalsItems[1]).toHaveAttribute('id', 'proposal1');
expect(closedProposalsItems[0]).toHaveAttribute('id', 'proposal3');
expect(closedProposalsItems[1]).toHaveAttribute('id', 'proposal4');
});
it('Displays info on no proposals', () => {
render(renderComponent([]));
expect(screen.queryByTestId('open-proposals')).not.toBeInTheDocument();

View File

@ -35,7 +35,11 @@ export const orderByDate = (arr: ProposalFieldsFragment[]) =>
orderBy(
arr,
[
(p) => new Date(p?.terms?.closingDatetime).getTime(),
(p) =>
p?.terms?.enactmentDatetime
? new Date(p?.terms?.enactmentDatetime).getTime()
: // has to be defaulted to 0 because new Date(null).getTime() -> NaN which is first when ordered
new Date(p?.terms?.closingDatetime || 0).getTime(),
(p) => new Date(p?.datetime).getTime(),
],
['asc', 'asc']

View File

@ -71,14 +71,6 @@ export const calculateOverstakedPenalty = (nodeId: string, nodes: Node[]) => {
new BigNumber(node.rewardScore?.rawValidatorScore || 0).dividedBy(tts)
)
.times(100);
console.log(
nodeId,
new BigNumber(node.rewardScore?.rawValidatorScore || 0).toString(),
tts.toString(),
new BigNumber(node.rewardScore?.rawValidatorScore || 0)
.dividedBy(tts)
.toString()
);
return penalty.isLessThan(0) ? new BigNumber(0) : penalty;
};