listAllContracts: order by popularity score

This commit is contained in:
mantikoros 2022-08-22 12:07:05 -05:00
parent 7a0d64e72f
commit 009c85b61a
2 changed files with 9 additions and 7 deletions

View File

@ -127,7 +127,7 @@ export async function listAllContracts(
n: number,
before?: string
): Promise<Contract[]> {
let q = query(contracts, orderBy('createdTime', 'desc'), limit(n))
let q = query(contracts, orderBy('popularityScore', 'desc'), limit(n))
if (before != null) {
const snap = await getDoc(doc(contracts, before))
q = query(q, startAfter(snap))

View File

@ -8,12 +8,14 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
const score = (popularity: number) => Math.tanh(Math.log10(popularity + 1))
const fields = contracts.map((market) => ({
loc: `https://manifold.markets/${market.creatorUsername}/${market.slug}`,
changefreq: market.volume24Hours > 10 ? 'hourly' : 'daily',
priority: score(market.popularityScore ?? 0),
lastmod: market.lastUpdatedTime,
})) as ISitemapField[]
const fields = contracts
.sort((x) => x.popularityScore ?? 0)
.map((market) => ({
loc: `https://manifold.markets/${market.creatorUsername}/${market.slug}`,
changefreq: market.volume24Hours > 10 ? 'hourly' : 'daily',
priority: score(market.popularityScore ?? 0),
lastmod: market.lastUpdatedTime,
})) as ISitemapField[]
return await getServerSideSitemap(ctx, fields)
}