fix ContractLeaderboard
This commit is contained in:
parent
ead13b4e08
commit
077bd946ff
|
@ -228,7 +228,9 @@ function ContractLeaderboard(props: { contract: Contract; bets: Bet[] }) {
|
||||||
|
|
||||||
const { userProfits, top5Ids } = useMemo(() => {
|
const { userProfits, top5Ids } = useMemo(() => {
|
||||||
// Create a map of userIds to total profits (including sales)
|
// Create a map of userIds to total profits (including sales)
|
||||||
const betsByUser = groupBy(bets, 'userId')
|
const openBets = bets.filter((bet) => !bet.isSold && !bet.sale)
|
||||||
|
const betsByUser = groupBy(openBets, 'userId')
|
||||||
|
|
||||||
const userProfits = mapValues(betsByUser, (bets) =>
|
const userProfits = mapValues(betsByUser, (bets) =>
|
||||||
sumBy(bets, (bet) => resolvedPayout(contract, bet) - bet.amount)
|
sumBy(bets, (bet) => resolvedPayout(contract, bet) - bet.amount)
|
||||||
)
|
)
|
||||||
|
@ -242,7 +244,6 @@ function ContractLeaderboard(props: { contract: Contract; bets: Bet[] }) {
|
||||||
}, [contract, bets])
|
}, [contract, bets])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('foo')
|
|
||||||
if (top5Ids.length > 0) {
|
if (top5Ids.length > 0) {
|
||||||
listUsers(top5Ids).then((users) => {
|
listUsers(top5Ids).then((users) => {
|
||||||
const sortedUsers = sortBy(users, (user) => -userProfits[user.id])
|
const sortedUsers = sortBy(users, (user) => -userProfits[user.id])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user