diff --git a/common/categories.ts b/common/categories.ts index 672f3200..f302e3f2 100644 --- a/common/categories.ts +++ b/common/categories.ts @@ -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) diff --git a/functions/src/scripts/convert-categories.ts b/functions/src/scripts/convert-categories.ts index 8fe90807..7b291202 100644 --- a/functions/src/scripts/convert-categories.ts +++ b/functions/src/scripts/convert-categories.ts @@ -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(adminFirestore.collection('groups')) const contracts = await getValues( 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( 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())