Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
add last reward round to an orchestrator's campaign view (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsoffer authored May 28, 2020
1 parent 43c72b2 commit 552df86
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 20 deletions.
58 changes: 57 additions & 1 deletion packages/explorer-2.0/components/CampaignView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import * as Utils from 'web3-utils'
import Card from '../Card'
import { abbreviateNumber } from '../../lib/utils'
import { Box } from 'theme-ui'
import { MdCheck, MdClose } from 'react-icons/md'
import ReactTooltip from 'react-tooltip'
import Help from '../../public/img/help.svg'

export default ({ transcoder }) => {
export default ({ currentRound, transcoder }) => {
const callsMade = transcoder.pools.filter(r => r.rewardTokens != null).length
return (
<Box sx={{ pt: 4 }}>
Expand Down Expand Up @@ -119,6 +122,59 @@ export default ({ transcoder }) => {
</Box>
}
/>
<Card
sx={{ flex: 1 }}
title={
<Flex sx={{ alignItems: 'center' }}>
<Box sx={{ color: 'muted' }}>Last Reward Round</Box>
<Flex>
<ReactTooltip
id="tooltip-last-reward-round"
className="tooltip"
place="top"
type="dark"
effect="solid"
/>
<Help
data-tip="The last round that an orchestrator received rewards while active. A checkmark indicates it called reward for the current round."
data-for="tooltip-last-reward-round"
sx={{
color: 'muted',
cursor: 'pointer',
ml: 1,
}}
/>
</Flex>
</Flex>
}
subtitle={
<Box
sx={{
fontSize: [3, 3, 4, 4, 5],
color: 'text',
position: 'relative',
fontWeight: 500,
lineHeight: 'heading',
fontFamily: 'monospace',
}}
>
<Flex sx={{ alignItems: 'center' }}>
{transcoder.lastRewardRound.id}{' '}
{transcoder.active && (
<Flex>
{transcoder.lastRewardRound.id === currentRound.id ? (
<MdCheck
sx={{ fontSize: 2, color: 'primary', ml: 1 }}
/>
) : (
<MdClose sx={{ fontSize: 2, color: 'red', ml: 1 }} />
)}
</Flex>
)}
</Flex>
</Box>
}
/>
</Box>
</>
</Box>
Expand Down
40 changes: 22 additions & 18 deletions packages/explorer-2.0/components/HistoryView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,30 @@ export default () => {
sx={{ overflow: 'hidden !important' }}
scrollThreshold={0.5}
dataLength={data && data.transactions.length}
next={() => {
next={async () => {
stopPolling()
if (!loading && data.transactions.length >= 10) {
fetchMore({
variables: {
skip: data.transactions.length,
},
updateQuery: (previousResult: any, { fetchMoreResult }: any) => {
if (!fetchMoreResult) {
return previousResult
}
return {
...previousResult,
transactions: [
...previousResult.transactions,
...fetchMoreResult.transactions,
],
}
},
})
try {
await fetchMore({
variables: {
skip: data.transactions.length,
},
updateQuery: (previousResult: any, { fetchMoreResult }: any) => {
if (!fetchMoreResult) {
return previousResult
}
return {
...previousResult,
transactions: [
...previousResult.transactions,
...fetchMoreResult.transactions,
],
}
},
})
} catch (e) {
return e
}
}
}}
hasMore={true}
Expand Down
7 changes: 6 additions & 1 deletion packages/explorer-2.0/pages/accounts/[account]/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ const Account = () => {
transcoder={data.transcoder}
/>
<Tabs tabs={tabs} />
{slug == 'campaign' && <CampaignView transcoder={data.transcoder} />}
{slug == 'campaign' && (
<CampaignView
currentRound={data.currentRound[0]}
transcoder={data.transcoder}
/>
)}
{slug == 'fees' && (
<FeesView
delegator={data.delegator}
Expand Down
3 changes: 3 additions & 0 deletions packages/explorer-2.0/queries/accountView.gql
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ query($account: ID!) {
active
totalStake
totalGeneratedFees
lastRewardRound {
id
}
pools(first: 30, orderBy: id, orderDirection: desc) {
rewardTokens
}
Expand Down

1 comment on commit 552df86

@vercel
Copy link

@vercel vercel bot commented on 552df86 May 28, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.