diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index 3a751c18..b31b8d04 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -266,12 +266,16 @@ export function listenForHotContracts( }) } -export async function getHotContracts() { - const data = await getValues(hotContractsQuery) - return sortBy( - chooseRandomSubset(data, 10), - (contract) => -1 * contract.volume24Hours - ) +const trendingContractsQuery = query( + contracts, + where('isResolved', '==', false), + where('visibility', '==', 'public'), + orderBy('popularityScore', 'desc'), + limit(10) +) + +export async function getTrendingContracts() { + return await getValues(trendingContractsQuery) } export async function getContractsBySlugs(slugs: string[]) { diff --git a/web/pages/index.tsx b/web/pages/index.tsx index 473189aa..d4ae5f47 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -1,4 +1,8 @@ -import { Contract, getContractsBySlugs } from 'web/lib/firebase/contracts' +import { + Contract, + getContractsBySlugs, + getTrendingContracts, +} from 'web/lib/firebase/contracts' import { Page } from 'web/components/page' import { LandingPagePanel } from 'web/components/landing-page-panel' import { Col } from 'web/components/layout/col' @@ -8,19 +12,7 @@ import { useSaveReferral } from 'web/hooks/use-save-referral' import { SEO } from 'web/components/SEO' export const getServerSideProps = redirectIfLoggedIn('/home', async (_) => { - // These hardcoded markets will be shown in the frontpage for signed-out users: - const hotContracts = await getContractsBySlugs([ - 'will-max-go-to-prom-with-a-girl', - 'will-ethereum-switch-to-proof-of-st', - 'will-russia-control-the-majority-of', - 'will-elon-musk-buy-twitter-this-yea', - 'will-trump-be-charged-by-the-grand', - 'will-spacex-launch-a-starship-into', - 'who-will-win-the-nba-finals-champio', - 'who-will-be-time-magazine-person-of', - 'will-congress-hold-any-hearings-abo-e21f987033b3', - 'will-at-least-10-world-cities-have', - ]) + const hotContracts = await getTrendingContracts() return { props: { hotContracts } } })