Signed out home page shows dynamic trending markets

This commit is contained in:
Ian Philips 2022-08-15 19:34:45 -06:00
parent 4002c23bee
commit d56435b9cd
2 changed files with 16 additions and 20 deletions

View File

@ -266,12 +266,16 @@ export function listenForHotContracts(
})
}
export async function getHotContracts() {
const data = await getValues<Contract>(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<Contract>(trendingContractsQuery)
}
export async function getContractsBySlugs(slugs: string[]) {

View File

@ -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 } }
})