Convert world and culture categories

This commit is contained in:
Ian Philips 2022-07-22 08:12:40 -06:00
parent 08fd27cb26
commit bfb11339ca
2 changed files with 15 additions and 11 deletions

View File

@ -31,10 +31,8 @@ export const EXCLUDED_CATEGORIES: category[] = [
'manifold',
'personal',
'covid',
'culture',
'gaming',
'crypto',
'world',
]
export const DEFAULT_CATEGORIES = difference(CATEGORY_LIST, EXCLUDED_CATEGORIES)

View File

@ -1,13 +1,8 @@
import * as admin from 'firebase-admin'
import { initAdmin } from './script-init'
initAdmin()
import { getValues, isProd } from '../utils'
import {
CATEGORIES_GROUP_SLUG_POSTFIX,
DEFAULT_CATEGORIES,
} from 'common/categories'
import { CATEGORIES_GROUP_SLUG_POSTFIX } from 'common/categories'
import { Group } from 'common/group'
import { uniq } from 'lodash'
import { Contract } from 'common/contract'
@ -18,9 +13,11 @@ import {
HOUSE_LIQUIDITY_PROVIDER_ID,
} from 'common/antes'
initAdmin()
const adminFirestore = admin.firestore()
async function convertCategoriesToGroups() {
const addGroupIdToContracts = async () => {
const groups = await getValues<Group>(adminFirestore.collection('groups'))
const contracts = await getValues<Contract>(
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>(
adminFirestore
.collection('contracts')
@ -77,7 +76,7 @@ async function convertCategoriesToGroups() {
createdTime: Date.now(),
anyoneCanJoin: true,
memberIds: [manifoldAccount],
about: 'Official group for all things related to ' + category,
about: 'Default group for all things related to ' + category,
mostRecentActivityTime: Date.now(),
contractIds: markets.map((market) => market.id),
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) {
convertCategoriesToGroups()
.then(() => process.exit())