delete markets cloud function
This commit is contained in:
parent
89f020ffcc
commit
6852314feb
|
@ -3,7 +3,6 @@ import * as admin from 'firebase-admin'
|
||||||
admin.initializeApp()
|
admin.initializeApp()
|
||||||
|
|
||||||
// export * from './keep-awake'
|
// export * from './keep-awake'
|
||||||
export * from './markets'
|
|
||||||
export * from './place-bet'
|
export * from './place-bet'
|
||||||
export * from './resolve-market'
|
export * from './resolve-market'
|
||||||
export * from './stripe'
|
export * from './stripe'
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
import * as functions from 'firebase-functions'
|
|
||||||
import * as admin from 'firebase-admin'
|
|
||||||
import * as _ from 'lodash'
|
|
||||||
|
|
||||||
import { getValues } from './utils'
|
|
||||||
import { Contract } from '../../common/contract'
|
|
||||||
import { getDpmProbability } from '../../common/calculate-dpm'
|
|
||||||
|
|
||||||
const cache = { lastUpdated: 0, data: '' }
|
|
||||||
|
|
||||||
export const markets = functions
|
|
||||||
.runWith({ minInstances: 1 })
|
|
||||||
.https.onRequest(async (req, res) => {
|
|
||||||
const contracts: Contract[] = await getValues(
|
|
||||||
firestore.collection('contracts').orderBy('volume24Hours', 'desc')
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!cache.data || Date.now() - cache.lastUpdated > 120 * 1000) {
|
|
||||||
const contractsInfo = contracts.map(getContractInfo)
|
|
||||||
cache.data = JSON.stringify(contractsInfo)
|
|
||||||
cache.lastUpdated = Date.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
res.status(200).send(cache.data)
|
|
||||||
})
|
|
||||||
|
|
||||||
const getContractInfo = ({
|
|
||||||
id,
|
|
||||||
creatorUsername,
|
|
||||||
creatorName,
|
|
||||||
createdTime,
|
|
||||||
closeTime,
|
|
||||||
question,
|
|
||||||
description,
|
|
||||||
slug,
|
|
||||||
pool,
|
|
||||||
totalShares,
|
|
||||||
volume7Days,
|
|
||||||
volume24Hours,
|
|
||||||
isResolved,
|
|
||||||
resolution,
|
|
||||||
}: Contract) => {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
creatorUsername,
|
|
||||||
creatorName,
|
|
||||||
createdTime,
|
|
||||||
closeTime,
|
|
||||||
question,
|
|
||||||
description,
|
|
||||||
url: `https://manifold.markets/${creatorUsername}/${slug}`,
|
|
||||||
pool: pool.YES + pool.NO,
|
|
||||||
probability: getDpmProbability(totalShares),
|
|
||||||
volume7Days,
|
|
||||||
volume24Hours,
|
|
||||||
isResolved,
|
|
||||||
resolution,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const firestore = admin.firestore()
|
|
Loading…
Reference in New Issue
Block a user