listAllContracts: order by popularity score
This commit is contained in:
parent
7a0d64e72f
commit
009c85b61a
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user