Daily movers cleanup
This commit is contained in:
parent
35aa6c0429
commit
2cc08ba9e7
|
@ -1,5 +1,5 @@
|
||||||
|
import { sortBy } from 'lodash'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { partition } from 'lodash'
|
|
||||||
import { contractPath } from 'web/lib/firebase/contracts'
|
import { contractPath } from 'web/lib/firebase/contracts'
|
||||||
import { CPMMContract } from 'common/contract'
|
import { CPMMContract } from 'common/contract'
|
||||||
import { formatPercent } from 'common/util/format'
|
import { formatPercent } from 'common/util/format'
|
||||||
|
@ -17,16 +17,14 @@ export function ProbChangeTable(props: {
|
||||||
|
|
||||||
if (!changes) return <LoadingIndicator />
|
if (!changes) return <LoadingIndicator />
|
||||||
|
|
||||||
const [positiveChanges, negativeChanges] = partition(
|
const descendingChanges = sortBy(changes, (c) => c.probChanges.day).reverse()
|
||||||
changes,
|
const ascendingChanges = sortBy(changes, (c) => c.probChanges.day)
|
||||||
(c) => c.probChanges.day > 0
|
|
||||||
)
|
|
||||||
|
|
||||||
const threshold = 0.01
|
const threshold = 0.01
|
||||||
const positiveAboveThreshold = positiveChanges.filter(
|
const positiveAboveThreshold = descendingChanges.filter(
|
||||||
(c) => c.probChanges.day > threshold
|
(c) => c.probChanges.day > threshold
|
||||||
)
|
)
|
||||||
const negativeAboveThreshold = negativeChanges.filter(
|
const negativeAboveThreshold = ascendingChanges.filter(
|
||||||
(c) => c.probChanges.day < threshold
|
(c) => c.probChanges.day < threshold
|
||||||
)
|
)
|
||||||
const maxRows = Math.min(
|
const maxRows = Math.min(
|
||||||
|
|
|
@ -8,20 +8,24 @@ import { useUser } from 'web/hooks/use-user'
|
||||||
|
|
||||||
export default function DailyMovers() {
|
export default function DailyMovers() {
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const bettorId = user?.id ?? undefined
|
|
||||||
|
|
||||||
const changes = useProbChanges({ bettorId })?.filter(
|
|
||||||
(c) => Math.abs(c.probChanges.day) >= 0.01
|
|
||||||
)
|
|
||||||
|
|
||||||
useTracking('view daily movers')
|
useTracking('view daily movers')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<Col className="pm:mx-10 gap-4 sm:px-4 sm:pb-4">
|
<Col className="pm:mx-10 gap-4 sm:px-4 sm:pb-4">
|
||||||
<Title className="mx-4 !mb-0 sm:mx-0" text="Daily movers" />
|
<Title className="mx-4 !mb-0 sm:mx-0" text="Daily movers" />
|
||||||
<ProbChangeTable changes={changes} full />
|
{user && <ProbChangesWrapper userId={user.id} />}
|
||||||
</Col>
|
</Col>
|
||||||
</Page>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ProbChangesWrapper(props: { userId: string }) {
|
||||||
|
const { userId } = props
|
||||||
|
|
||||||
|
const changes = useProbChanges({ bettorId: userId })?.filter(
|
||||||
|
(c) => Math.abs(c.probChanges.day) >= 0.01
|
||||||
|
)
|
||||||
|
|
||||||
|
return <ProbChangeTable changes={changes} full />
|
||||||
|
}
|
||||||
|
|
|
@ -286,9 +286,9 @@ function GroupSection(props: {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function DailyMoversSection(props: { userId: string | null | undefined }) {
|
function DailyMoversSection(props: { userId: string }) {
|
||||||
const { userId } = props
|
const { userId } = props
|
||||||
const changes = useProbChanges({ bettorId: userId ?? undefined })?.filter(
|
const changes = useProbChanges({ bettorId: userId })?.filter(
|
||||||
(c) => Math.abs(c.probChanges.day) >= 0.01
|
(c) => Math.abs(c.probChanges.day) >= 0.01
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user