Skip to content

Commit d51a6e4

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

File tree

2 files changed

+29
-0
lines changed

2 files changed

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

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)