diff --git a/web/components/contract/prob-change-table.tsx b/web/components/contract/prob-change-table.tsx
index 727fed35..1832a638 100644
--- a/web/components/contract/prob-change-table.tsx
+++ b/web/components/contract/prob-change-table.tsx
@@ -12,8 +12,9 @@ import { formatNumericProbability } from 'common/pseudo-numeric'
export function ProfitChangeTable(props: {
contracts: CPMMBinaryContract[]
metrics: ContractMetrics[]
+ maxRows?: number
}) {
- const { contracts, metrics } = props
+ const { contracts, metrics, maxRows } = props
const contractProfit = metrics.map(
(m) => [m.contractId, m.from?.day.profit ?? 0] as const
@@ -27,7 +28,7 @@ export function ProfitChangeTable(props: {
positiveProfit.map(([contractId]) =>
contracts.find((c) => c.id === contractId)
)
- )
+ ).slice(0, maxRows)
const negativeProfit = sortBy(
contractProfit.filter(([, profit]) => profit < 0),
@@ -37,7 +38,7 @@ export function ProfitChangeTable(props: {
negativeProfit.map(([contractId]) =>
contracts.find((c) => c.id === contractId)
)
- )
+ ).slice(0, maxRows)
if (positive.length === 0 && negative.length === 0)
return
None
diff --git a/web/hooks/use-user.ts b/web/hooks/use-user.ts
index 793c11ff..e1310382 100644
--- a/web/hooks/use-user.ts
+++ b/web/hooks/use-user.ts
@@ -47,10 +47,7 @@ export const usePrefetchUsers = (userIds: string[]) => {
)
}
-export const useUserContractMetricsByProfit = (
- userId: string,
- count: number
-) => {
+export const useUserContractMetricsByProfit = (userId: string, count = 50) => {
const positiveResult = useFirestoreQueryData(
['contract-metrics-descending', userId, count],
getUserContractMetricsQuery(userId, count, 'desc')
@@ -71,10 +68,13 @@ export const useUserContractMetricsByProfit = (
if (!positiveResult.data || !negativeResult.data || !contracts)
return undefined
- const filteredContracts = filterDefined(contracts) as CPMMBinaryContract[]
- const filteredMetrics = metrics.filter(
- (m) => m.from && Math.abs(m.from.day.profit) >= 0.5
- )
+ const filteredContracts = filterDefined(contracts).filter(
+ (c) => !c.isResolved
+ ) as CPMMBinaryContract[]
+ const filteredMetrics = metrics
+ .filter((m) => m.from && Math.abs(m.from.day.profit) >= 0.5)
+ .filter((m) => filteredContracts.find((c) => c.id === m.contractId))
+
return { contracts: filteredContracts, metrics: filteredMetrics }
}
diff --git a/web/pages/daily-movers.tsx b/web/pages/daily-movers.tsx
index f8426d7f..aa2c067b 100644
--- a/web/pages/daily-movers.tsx
+++ b/web/pages/daily-movers.tsx
@@ -28,7 +28,7 @@ export default function DailyMovers() {
function ProbChangesWrapper(props: { userId: string }) {
const { userId } = props
- const data = useUserContractMetricsByProfit(userId, 50)
+ const data = useUserContractMetricsByProfit(userId)
if (!data) return
diff --git a/web/pages/home/index.tsx b/web/pages/home/index.tsx
index 4d46b12e..6520c19a 100644
--- a/web/pages/home/index.tsx
+++ b/web/pages/home/index.tsx
@@ -95,8 +95,7 @@ export default function Home() {
}, [user, sections])
const contractMetricsByProfit = useUserContractMetricsByProfit(
- user?.id ?? '_',
- 3
+ user?.id ?? '_'
)
const trendingContracts = useTrendingContracts(6)
@@ -494,7 +493,7 @@ function DailyMoversSection(props: {
return (
-
+
)
}
@@ -530,8 +529,7 @@ export function DailyProfit(props: { user: User | null | undefined }) {
const { user } = props
const contractMetricsByProfit = useUserContractMetricsByProfit(
- user?.id ?? '_',
- 100
+ user?.id ?? '_'
)
const profit = sum(
contractMetricsByProfit?.metrics.map((m) =>