Convert world and culture categories
This commit is contained in:
parent
08fd27cb26
commit
bfb11339ca
|
@ -31,10 +31,8 @@ export const EXCLUDED_CATEGORIES: category[] = [
|
||||||
'manifold',
|
'manifold',
|
||||||
'personal',
|
'personal',
|
||||||
'covid',
|
'covid',
|
||||||
'culture',
|
|
||||||
'gaming',
|
'gaming',
|
||||||
'crypto',
|
'crypto',
|
||||||
'world',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export const DEFAULT_CATEGORIES = difference(CATEGORY_LIST, EXCLUDED_CATEGORIES)
|
export const DEFAULT_CATEGORIES = difference(CATEGORY_LIST, EXCLUDED_CATEGORIES)
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
import * as admin from 'firebase-admin'
|
import * as admin from 'firebase-admin'
|
||||||
|
|
||||||
import { initAdmin } from './script-init'
|
import { initAdmin } from './script-init'
|
||||||
initAdmin()
|
|
||||||
|
|
||||||
import { getValues, isProd } from '../utils'
|
import { getValues, isProd } from '../utils'
|
||||||
import {
|
import { CATEGORIES_GROUP_SLUG_POSTFIX } from 'common/categories'
|
||||||
CATEGORIES_GROUP_SLUG_POSTFIX,
|
|
||||||
DEFAULT_CATEGORIES,
|
|
||||||
} from 'common/categories'
|
|
||||||
import { Group } from 'common/group'
|
import { Group } from 'common/group'
|
||||||
import { uniq } from 'lodash'
|
import { uniq } from 'lodash'
|
||||||
import { Contract } from 'common/contract'
|
import { Contract } from 'common/contract'
|
||||||
|
@ -18,9 +13,11 @@ import {
|
||||||
HOUSE_LIQUIDITY_PROVIDER_ID,
|
HOUSE_LIQUIDITY_PROVIDER_ID,
|
||||||
} from 'common/antes'
|
} from 'common/antes'
|
||||||
|
|
||||||
|
initAdmin()
|
||||||
|
|
||||||
const adminFirestore = admin.firestore()
|
const adminFirestore = admin.firestore()
|
||||||
|
|
||||||
async function convertCategoriesToGroups() {
|
const addGroupIdToContracts = async () => {
|
||||||
const groups = await getValues<Group>(adminFirestore.collection('groups'))
|
const groups = await getValues<Group>(adminFirestore.collection('groups'))
|
||||||
const contracts = await getValues<Contract>(
|
const contracts = await getValues<Contract>(
|
||||||
adminFirestore.collection('contracts')
|
adminFirestore.collection('contracts')
|
||||||
|
@ -38,8 +35,10 @@ async function convertCategoriesToGroups() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const category of Object.values(DEFAULT_CATEGORIES)) {
|
const convertCategoriesToGroupsInternal = async (categories: string[]) => {
|
||||||
|
for (const category of categories) {
|
||||||
const markets = await getValues<Contract>(
|
const markets = await getValues<Contract>(
|
||||||
adminFirestore
|
adminFirestore
|
||||||
.collection('contracts')
|
.collection('contracts')
|
||||||
|
@ -77,7 +76,7 @@ async function convertCategoriesToGroups() {
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
anyoneCanJoin: true,
|
anyoneCanJoin: true,
|
||||||
memberIds: [manifoldAccount],
|
memberIds: [manifoldAccount],
|
||||||
about: 'Official group for all things related to ' + category,
|
about: 'Default group for all things related to ' + category,
|
||||||
mostRecentActivityTime: Date.now(),
|
mostRecentActivityTime: Date.now(),
|
||||||
contractIds: markets.map((market) => market.id),
|
contractIds: markets.map((market) => market.id),
|
||||||
chatDisabled: true,
|
chatDisabled: true,
|
||||||
|
@ -103,6 +102,13 @@ async function convertCategoriesToGroups() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function convertCategoriesToGroups() {
|
||||||
|
// await addGroupIdToContracts()
|
||||||
|
// const defaultCategories = Object.values(DEFAULT_CATEGORIES)
|
||||||
|
const moreCategories = ['world', 'culture']
|
||||||
|
await convertCategoriesToGroupsInternal(moreCategories)
|
||||||
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
convertCategoriesToGroups()
|
convertCategoriesToGroups()
|
||||||
.then(() => process.exit())
|
.then(() => process.exit())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user