Skip to content

Commit

Permalink
Fix past elections total staked value (#4578)
Browse files Browse the repository at this point in the history
* fix/past-election#4090

* fix/past_elections
  • Loading branch information
akiowebstar authored Oct 24, 2023
1 parent 3bae157 commit 1745714
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const PastElections = () => {
<PastElectionsListHeaders $colLayout={PastElectionsColLayout}>
<SortHeader {...getSortProps('cycleId')}>Round</SortHeader>
<SortHeader {...getSortProps('updatedAt')}>Election ended at</SortHeader>
<ListHeader>Total staked</ListHeader>
<ListHeader>Total Candidates staked</ListHeader>
<ListHeader>Total Votes staked</ListHeader>
<ListHeader>Revealed votes</ListHeader>
<ListHeader>Total candidates</ListHeader>
</PastElectionsListHeaders>
Expand All @@ -65,7 +66,7 @@ export const PastElections = () => {
return <PageLayout header={header} main={displayMain()} />
}

export const PastElectionsColLayout = '48px 176px 156px 100px 100px'
export const PastElectionsColLayout = '48px 176px 140px 140px 100px 100px'

const PastElectionsListHeaders = styled(ListHeaders)`
grid-column-gap: 24px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const PastElectionTabs = ({ election }: PastElectionTabsProps) => {
revealed: !!myVote,
member: votingResult.candidate.member,
sumOfAllStakes: votingResult.totalStake,
totalStake: election.totalStake,
totalStake: election.totalVoteStake,
votes: votingResult.votes.length,
index: index + 1,
myVotes: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) =>
) : (
<></>
)}
<TokenValue value={election.totalStake} />
<TokenValue value={election.totalCandidatesStake} />
<TokenValue value={election.totalVoteStake} />
<Fraction numerator={election.revealedVotes} denominator={election.totalVotes} sameSize />
<CountInfo count={election.totalCandidates} />
</PastElectionsListRowItem>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/ui/src/council/queries/council.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ fragment PastElectionRoundFields on ElectionRound {
}
castVotes {
voteForId
stake
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/ui/src/council/types/PastElection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export interface PastElection {
id: string
cycleId: number
finishedAtBlock?: Block
totalStake: BN
totalCandidatesStake: BN
totalCandidates: number
revealedVotes: number
totalVotes: number
totalVoteStake: BN
}

export interface PastElectionWithDetails extends PastElection {
Expand All @@ -30,17 +31,17 @@ export const asPastElection = (fields: PastElectionRoundFieldsFragment): PastEle
id: fields.id,
cycleId: fields.cycleId,
finishedAtBlock: maybeAsBlock(fields.endedAtBlock, fields.endedAtTime, fields.endedAtNetwork),
totalStake: sumStakes(fields.candidates),
totalCandidatesStake: sumStakes(fields.candidates),
totalCandidates: fields.candidates.length,
revealedVotes: fields.castVotes.filter((castVote) => castVote.voteForId).length,
totalVotes: fields.castVotes.length,
totalVoteStake: sumStakes(fields.castVotes),
})

export const asPastElectionWithDetails = (
fields: PastElectionRoundDetailedFieldsFragment
): PastElectionWithDetails => ({
...asPastElection(fields),
totalStake: sumStakes(fields.castVotes),
votingResults: fields.candidates.map((candidate) => {
const candidateVotes = fields.castVotes.filter(({ voteForId }) => voteForId === candidate.id)

Expand Down

2 comments on commit 1745714

@vercel
Copy link

@vercel vercel bot commented on 1745714 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 1745714 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2 – ./

pioneer-2-joystream.vercel.app
pioneer-2.vercel.app
pioneer-2-git-dev-joystream.vercel.app

Please sign in to comment.