listAllContracts: order by popularity score
This commit is contained in:
parent
7a0d64e72f
commit
009c85b61a
|
@ -127,7 +127,7 @@ export async function listAllContracts(
|
||||||
n: number,
|
n: number,
|
||||||
before?: string
|
before?: string
|
||||||
): Promise<Contract[]> {
|
): Promise<Contract[]> {
|
||||||
let q = query(contracts, orderBy('createdTime', 'desc'), limit(n))
|
let q = query(contracts, orderBy('popularityScore', 'desc'), limit(n))
|
||||||
if (before != null) {
|
if (before != null) {
|
||||||
const snap = await getDoc(doc(contracts, before))
|
const snap = await getDoc(doc(contracts, before))
|
||||||
q = query(q, startAfter(snap))
|
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 score = (popularity: number) => Math.tanh(Math.log10(popularity + 1))
|
||||||
|
|
||||||
const fields = contracts.map((market) => ({
|
const fields = contracts
|
||||||
loc: `https://manifold.markets/${market.creatorUsername}/${market.slug}`,
|
.sort((x) => x.popularityScore ?? 0)
|
||||||
changefreq: market.volume24Hours > 10 ? 'hourly' : 'daily',
|
.map((market) => ({
|
||||||
priority: score(market.popularityScore ?? 0),
|
loc: `https://manifold.markets/${market.creatorUsername}/${market.slug}`,
|
||||||
lastmod: market.lastUpdatedTime,
|
changefreq: market.volume24Hours > 10 ? 'hourly' : 'daily',
|
||||||
})) as ISitemapField[]
|
priority: score(market.popularityScore ?? 0),
|
||||||
|
lastmod: market.lastUpdatedTime,
|
||||||
|
})) as ISitemapField[]
|
||||||
|
|
||||||
return await getServerSideSitemap(ctx, fields)
|
return await getServerSideSitemap(ctx, fields)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user