73fc67955d
* Add components for CPM landing and charity pages * Remove misc.ts to fix build * Set up cloud function for writing txns * More plumbing for txns * Fix up API call * Use Date.now() to keep timestamps simple * Some styles for charity list page * Hard code charities data * Pass charity data to charity page * Update txn type * Listen for charity txns * Handle txn to non-user by burning it * Read txns for charity card and charity page. * Set images to object contain * Clean up txn types * Move pic to top of card. Other misc styling. * Update charity short & long descriptions * Add `token` and `category` to Txn * Fix breakages * Show Charity link in the sidebar * Fix typing issues * Fix not reading from the right type * Switch out icon * Also show Charity icon on mobile * Update copy Co-authored-by: Austin Chen <akrolsmir@gmail.com> Co-authored-by: James Grugett <jahooma@gmail.com>
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
// This code is copied from https://firebase.google.com/docs/firestore/solutions/schedule-export
|
|
//
|
|
// To deploy after any changes:
|
|
// `yarn deploy`
|
|
//
|
|
// To manually run a backup: Click "Run Now" on the backupDb script
|
|
// https://console.cloud.google.com/cloudscheduler?project=mantic-markets
|
|
//
|
|
// Backups are here:
|
|
// https://console.cloud.google.com/storage/browser/manifold-firestore-backup
|
|
//
|
|
// To import the data into dev Firestore (from https://firebase.google.com/docs/firestore/manage-data/move-data):
|
|
// 0. Open up a cloud shell from manticmarkets@gmail.com: https://console.cloud.google.com/home/dashboard?cloudshell=true
|
|
// 1. `gcloud config set project dev-mantic-markets`
|
|
// 2. Get the backup timestamp e.g. `2022-01-25T21:19:20_6605`
|
|
// 3. `gcloud firestore import gs://manifold-firestore-backup/2022-01-25T21:19:20_6605 --async`
|
|
// 4. (Optional) `gcloud firestore operations list` to check progress
|
|
|
|
import * as functions from 'firebase-functions'
|
|
import * as firestore from '@google-cloud/firestore'
|
|
const client = new firestore.v1.FirestoreAdminClient()
|
|
|
|
const bucket = 'gs://manifold-firestore-backup'
|
|
|
|
export const backupDb = functions.pubsub
|
|
.schedule('every 24 hours')
|
|
.onRun((context) => {
|
|
const projectId = process.env.GCP_PROJECT || process.env.GCLOUD_PROJECT
|
|
const databaseName = client.databasePath(projectId!, '(default)')
|
|
|
|
return client
|
|
.exportDocuments({
|
|
name: databaseName,
|
|
outputUriPrefix: bucket,
|
|
// Leave collectionIds empty to export all collections
|
|
// or set to a list of collection IDs to export,
|
|
// collectionIds: ['users', 'posts']
|
|
// NOTE: Subcollections are not backed up by default
|
|
collectionIds: [
|
|
'contracts',
|
|
'folds',
|
|
'private-users',
|
|
'stripe-transactions',
|
|
'users',
|
|
'bets',
|
|
'comments',
|
|
'followers',
|
|
'answers',
|
|
'txns',
|
|
],
|
|
})
|
|
.then((responses) => {
|
|
const response = responses[0]
|
|
console.log(`Operation Name: ${response['name']}`)
|
|
})
|
|
.catch((err) => {
|
|
console.error(err)
|
|
throw new Error('Export operation failed')
|
|
})
|
|
})
|