Include older contracts in fold feed
This commit is contained in:
parent
2e3f1b4c52
commit
be82406c4d
|
@ -26,7 +26,8 @@ function lastActivityTime(contract: Contract) {
|
||||||
// - Market resolved
|
// - Market resolved
|
||||||
export function findActiveContracts(
|
export function findActiveContracts(
|
||||||
allContracts: Contract[],
|
allContracts: Contract[],
|
||||||
recentComments: Comment[]
|
recentComments: Comment[],
|
||||||
|
daysAgo = 3
|
||||||
) {
|
) {
|
||||||
const idToActivityTime = new Map<string, number>()
|
const idToActivityTime = new Map<string, number>()
|
||||||
function record(contractId: string, time: number) {
|
function record(contractId: string, time: number) {
|
||||||
|
@ -40,7 +41,7 @@ export function findActiveContracts(
|
||||||
// Find contracts with activity in the last 3 days
|
// Find contracts with activity in the last 3 days
|
||||||
const DAY_IN_MS = 24 * 60 * 60 * 1000
|
const DAY_IN_MS = 24 * 60 * 60 * 1000
|
||||||
for (const contract of allContracts || []) {
|
for (const contract of allContracts || []) {
|
||||||
if (lastActivityTime(contract) > Date.now() - 3 * DAY_IN_MS) {
|
if (lastActivityTime(contract) > Date.now() - daysAgo * DAY_IN_MS) {
|
||||||
contracts.push(contract)
|
contracts.push(contract)
|
||||||
record(contract.id, lastActivityTime(contract))
|
record(contract.id, lastActivityTime(contract))
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ export async function getStaticProps(props: { params: { foldSlug: string } }) {
|
||||||
|
|
||||||
const activeContracts = findActiveContracts(
|
const activeContracts = findActiveContracts(
|
||||||
contracts,
|
contracts,
|
||||||
_.flatten(contractComments)
|
_.flatten(contractComments),
|
||||||
|
365
|
||||||
)
|
)
|
||||||
const activeContractBets = await Promise.all(
|
const activeContractBets = await Promise.all(
|
||||||
activeContracts.map((contract) => listAllBets(contract.id))
|
activeContracts.map((contract) => listAllBets(contract.id))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user