diff --git a/api/config/custom-environment-variables.json b/api/config/custom-environment-variables.json index 4199fbce2..3e49afbd0 100644 --- a/api/config/custom-environment-variables.json +++ b/api/config/custom-environment-variables.json @@ -17,6 +17,7 @@ "slackViewOpenUrl": "https://slack.com/api/views.open", "snootySecret": "SNOOTY_SECRET", "jobQueueCollection": "JOB_QUEUE_COL_NAME", + "projectsCollection": "PROJECTS_COL_NAME", "entitlementCollection": "USER_ENTITLEMENT_COL_NAME", "dashboardUrl": "DASHBOARD_URL", "repoBranchesCollection": "REPO_BRANCHES_COL_NAME", diff --git a/api/config/default.json b/api/config/default.json index 16d56ce57..a7988e98c 100644 --- a/api/config/default.json +++ b/api/config/default.json @@ -17,6 +17,7 @@ "slackViewOpenUrl": "https://slack.com/api/views.open", "snootySecret": "SNOOTY_SECRET", "jobQueueCollection": "JOB_QUEUE_COL_NAME", + "projectsCollection": "PROJECTS_COL_NAME", "entitlementCollection": "USER_ENTITLEMENT_COL_NAME", "repoBranchesCollection": "REPO_BRANCHES_COL_NAME", "docsetsCollection": "DOCSETS_COL_NAME", @@ -37,6 +38,7 @@ "stg": { "dbName": "pool_test", "jobQueueCollection": "dotcom_queue", + "projectsCollection": "PROJECTS_COL_NAME", "jobsQueueUrl": "https://sqs.us-east-2.amazonaws.com/216656347858/autobuilder-jobs-queue-dotcomstg", "jobUpdatesQueueUrl": "https://sqs.us-east-2.amazonaws.com/216656347858/autobuilder-job-updates-queue-dotcomstg", "parallelStgName": "dotcomstg" @@ -44,6 +46,7 @@ "prd": { "dbName": "pool", "jobQueueCollection": "dotcom_queue", + "projectsCollection": "PROJECTS_COL_NAME", "jobsQueueUrl": "https://sqs.us-east-2.amazonaws.com/216656347858/autobuilder-jobs-queue-dotcomprd", "jobUpdatesQueueUrl": "https://sqs.us-east-2.amazonaws.com/216656347858/autobuilder-job-updates-queue-dotcomprd", "parallelStgName": "dotcomprd" diff --git a/cdk-infra/lib/constructs/api/webhook-env-construct.ts b/cdk-infra/lib/constructs/api/webhook-env-construct.ts index 800b9277d..fd8f9cd01 100644 --- a/cdk-infra/lib/constructs/api/webhook-env-construct.ts +++ b/cdk-infra/lib/constructs/api/webhook-env-construct.ts @@ -42,6 +42,7 @@ export class WebhookEnvConstruct extends Construct { SNOOTY_DB_NAME: snootyDbName, REPO_BRANCHES_COL_NAME: repoBranchesCollection, DOCSETS_COL_NAME: docsetsCollection, + PROJECTS_COL_NAME: 'projects', JOB_QUEUE_COL_NAME: jobCollection, NODE_CONFIG_DIR: './config', JOBS_QUEUE_URL: jobsQueue.queueUrl, diff --git a/cdk-infra/lib/constructs/worker/worker-env-construct.ts b/cdk-infra/lib/constructs/worker/worker-env-construct.ts index 1b532a16c..54d9737ac 100644 --- a/cdk-infra/lib/constructs/worker/worker-env-construct.ts +++ b/cdk-infra/lib/constructs/worker/worker-env-construct.ts @@ -92,6 +92,7 @@ export class WorkerEnvConstruct extends Construct { REPO_BRANCHES_COL_NAME: repoBranchesCollection, DOCSETS_COL_NAME: docsetsCollection, JOB_QUEUE_COL_NAME: jobCollection, + PROJECTS_COL_NAME: 'projects', CDN_INVALIDATOR_SERVICE_URL: getCdnInvalidatorUrl(env), SEARCH_INDEX_BUCKET: 'docs-search-indexes-test', SEARCH_INDEX_FOLDER: getSearchIndexFolder(env), diff --git a/cdk-infra/static/api/config/custom-environment-variables.json b/cdk-infra/static/api/config/custom-environment-variables.json index 8d554d1b5..cf328ded6 100644 --- a/cdk-infra/static/api/config/custom-environment-variables.json +++ b/cdk-infra/static/api/config/custom-environment-variables.json @@ -17,6 +17,7 @@ "slackViewOpenUrl": "https://slack.com/api/views.open", "snootySecret": "SNOOTY_SECRET", "jobQueueCollection": "JOB_QUEUE_COL_NAME", + "projectsCollection": "PROJECTS_COL_NAME", "entitlementCollection": "USER_ENTITLEMENT_COL_NAME", "dashboardUrl": "DASHBOARD_URL", "repoBranchesCollection": "REPO_BRANCHES_COL_NAME", diff --git a/cdk-infra/static/api/config/default.json b/cdk-infra/static/api/config/default.json index 3758dea37..481f695d3 100644 --- a/cdk-infra/static/api/config/default.json +++ b/cdk-infra/static/api/config/default.json @@ -17,6 +17,7 @@ "slackViewOpenUrl": "https://slack.com/api/views.open", "snootySecret": "SNOOTY_SECRET", "jobQueueCollection": "JOB_QUEUE_COL_NAME", + "projectsCollection": "PROJECTS_COL_NAME", "entitlementCollection": "USER_ENTITLEMENT_COL_NAME", "repoBranchesCollection": "REPO_BRANCHES_COL_NAME", "docsetsCollection": "DOCSETS_COL_NAME", diff --git a/config/default.json b/config/default.json index 8a089b421..ae9b5f9a7 100644 --- a/config/default.json +++ b/config/default.json @@ -12,6 +12,7 @@ "githubBotPW": "q1w", "fastlyDochubMap": "devfslydochubmap", "entitlementCollection": "entitlements", + "projectsCollection": "projects", "docsetsCollection": "docsets", "MONGO_TIMEOUT_S": 1500, "JOB_TIMEOUT_S": 900, diff --git a/config/test.json b/config/test.json index 5a17611ea..aded7d904 100644 --- a/config/test.json +++ b/config/test.json @@ -12,6 +12,7 @@ "githubBotPW": "q1w", "fastlyDochubMap": "devfslydochubmap", "entitlementCollection": "entitlements", + "projectsCollection": "projects", "docsetsCollection": "docsets", "MONGO_TIMEOUT_S": 1, "JOB_TIMEOUT_S": 10, diff --git a/src/repositories/projectsRepository.ts b/src/repositories/projectsRepository.ts index c8486a255..ea5085549 100644 --- a/src/repositories/projectsRepository.ts +++ b/src/repositories/projectsRepository.ts @@ -3,12 +3,13 @@ import { IConfig } from 'config'; import { BaseRepository } from './baseRepository'; import { ILogger } from '../services/logger'; -/** - * Project information from docs_metadata.projects for parser builds. - */ +//Project information from docs_metadata.projects for parser builds. + +const projectsCollectionName = process.env.PROJECTS_COL_NAME || 'projects'; + export class ProjectsRepository extends BaseRepository { - constructor(db: Db, config: IConfig, logger: ILogger) { - super(config, logger, 'ProjectsRepository', db.collection('projects')); + constructor(db: mongodb.Db, config: IConfig, logger: ILogger) { + super(config, logger, 'ProjectsRepository', db.collection(projectsCollectionName)); } async getProjectEntry(name: string): Promise | null> {