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 { partition } from 'lodash'
|
||||
import { contractPath } from 'web/lib/firebase/contracts'
|
||||
import { CPMMContract } from 'common/contract'
|
||||
import { formatPercent } from 'common/util/format'
|
||||
|
@ -17,16 +17,14 @@ export function ProbChangeTable(props: {
|
|||
|
||||
if (!changes) return <LoadingIndicator />
|
||||
|
||||
const [positiveChanges, negativeChanges] = partition(
|
||||
changes,
|
||||
(c) => c.probChanges.day > 0
|
||||
)
|
||||
const descendingChanges = sortBy(changes, (c) => c.probChanges.day).reverse()
|
||||
const ascendingChanges = sortBy(changes, (c) => c.probChanges.day)
|
||||
|
||||
const threshold = 0.01
|
||||
const positiveAboveThreshold = positiveChanges.filter(
|
||||
const positiveAboveThreshold = descendingChanges.filter(
|
||||
(c) => c.probChanges.day > threshold
|
||||
)
|
||||
const negativeAboveThreshold = negativeChanges.filter(
|
||||
const negativeAboveThreshold = ascendingChanges.filter(
|
||||
(c) => c.probChanges.day < threshold
|
||||
)
|
||||
const maxRows = Math.min(
|
||||
|
|
|
@ -8,20 +8,24 @@ import { useUser } from 'web/hooks/use-user'
|
|||
|
||||
export default function DailyMovers() {
|
||||
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')
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<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" />
|
||||
<ProbChangeTable changes={changes} full />
|
||||
{user && <ProbChangesWrapper userId={user.id} />}
|
||||
</Col>
|
||||
</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 changes = useProbChanges({ bettorId: userId ?? undefined })?.filter(
|
||||
const changes = useProbChanges({ bettorId: userId })?.filter(
|
||||
(c) => Math.abs(c.probChanges.day) >= 0.01
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user