Skip to content

Commit 4924f3f

Browse files
committed
Add migration to create department id blacklist
1 parent 9418846 commit 4924f3f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable no-console */
2+
import { readFile } from 'node:fs/promises';
3+
import { BaseMigration } from '~/core/database';
4+
5+
interface ExternalDepartmentId {
6+
departmentId: string;
7+
name?: string;
8+
}
9+
10+
export class CreateUsedDeptIdListMigration extends BaseMigration {
11+
async up() {
12+
const filePath = new URL(
13+
'../../../../../All-Department-Ids-From-Intaact.csv',
14+
import.meta.url,
15+
);
16+
const fileContent = await readFile(filePath, 'utf-8');
17+
const rows = fileContent.trim().split(/\r?\n/).slice(1); // Skip header
18+
const _idList: ExternalDepartmentId[] = rows.flatMap((row) => {
19+
const [departmentId, name] = row.split(',');
20+
if (departmentId) {
21+
return { departmentId, name };
22+
}
23+
return [];
24+
});
25+
}
26+
}

src/components/project/project.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ProjectEngagementConnectionResolver } from './engagement-connection.res
1414
import { FinancialApproverModule } from './financial-approver/financial-approver.module';
1515
import * as handlers from './handlers';
1616
import { InternshipProjectResolver } from './internship-project.resolver';
17+
import { CreateUsedDeptIdListMigration } from './migrations/create-used-dept-id-list.migration';
1718
import { FixDeptIdLabelMigration } from './migrations/fix-dept-id-label.migration';
1819
import { RenameTranslationToMomentumMigration } from './migrations/rename-translation-to-momentum.migration';
1920
import { ProjectEngagementIdResolvers } from './project-engagement-id.resolver';
@@ -55,6 +56,7 @@ import { ProjectWorkflowModule } from './workflow/project-workflow.module';
5556
...Object.values(ConcreteRepos),
5657
ProjectLoader,
5758
...Object.values(handlers),
59+
CreateUsedDeptIdListMigration,
5860
RenameTranslationToMomentumMigration,
5961
FixDeptIdLabelMigration,
6062
],

0 commit comments

Comments
 (0)