manifold/web/lib/firebase/stats.ts
Marshall Polaris 0067bee94b
Compute stats in Firebase instead of Vercel (#584)
* Add stats updating cloud function

* Read stats from database on client instead of computing them

* Improve logging for stats updater

* Tidying up
2022-06-26 14:42:42 -07:00

16 lines
379 B
TypeScript

import {
CollectionReference,
doc,
collection,
getDoc,
} from 'firebase/firestore'
import { db } from 'web/lib/firebase/init'
import { Stats } from 'common/stats'
const statsCollection = collection(db, 'stats') as CollectionReference<Stats>
const statsDoc = doc(statsCollection, 'stats')
export const getStats = async () => {
return (await getDoc(statsDoc)).data()
}