2022-01-13 01:53:50 +00:00
|
|
|
import * as admin from 'firebase-admin'
|
|
|
|
import * as _ from 'lodash'
|
|
|
|
|
2022-01-30 21:11:01 +00:00
|
|
|
import { initAdmin } from './script-init'
|
2022-04-20 04:31:46 +00:00
|
|
|
initAdmin()
|
2022-01-13 01:53:50 +00:00
|
|
|
|
2022-05-10 20:59:38 +00:00
|
|
|
import { Contract } from 'common/contract'
|
2022-01-13 01:53:50 +00:00
|
|
|
|
|
|
|
const firestore = admin.firestore()
|
|
|
|
|
|
|
|
async function makeContractsPublic() {
|
|
|
|
console.log('Updating contracts to be public')
|
|
|
|
|
|
|
|
const snapshot = await firestore.collection('contracts').get()
|
|
|
|
const contracts = snapshot.docs.map((doc) => doc.data() as Contract)
|
|
|
|
|
|
|
|
console.log('Loaded', contracts.length, 'contracts')
|
|
|
|
|
|
|
|
for (const contract of contracts) {
|
|
|
|
const contractRef = firestore.doc(`contracts/${contract.id}`)
|
|
|
|
|
|
|
|
console.log('Updating', contract.question)
|
|
|
|
await contractRef.update({ visibility: 'public' })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (require.main === module) makeContractsPublic().then(() => process.exit())
|