Skip to content

Commit 27c2d7e

Browse files
fix(domain-acl): fix reviewer type
1 parent ac47f69 commit 27c2d7e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/config/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ export const PhaseTypeIds = {
99
Review: 4,
1010
IterativeReview: 18
1111
};
12+
13+
export const ProjectCategories = {
14+
First2Finish: 38,
15+
}
16+
17+
export const ResourceRoleTypeIds = {
18+
IterativeReviewer: 21,
19+
Reviewer: 4
20+
}

src/domain/LegacyChallenge.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import LegacyPhaseDomain from "./Phase";
99
import LegacyReviewDomain from "./Review";
1010
import LegacyResourceDomain from "./Resource";
1111
import LegacyPrizeDomain from "./Prize";
12-
import { PhaseStatusIds, PhaseTypeIds } from '../config/constants';
12+
import { PhaseStatusIds, PhaseTypeIds, ProjectCategories, ResourceRoleTypeIds } from '../config/constants';
1313
import moment from "moment";
1414

1515
class LegacyChallengeDomain {
@@ -19,6 +19,8 @@ class LegacyChallengeDomain {
1919
}
2020

2121
public async closeChallenge(input:CloseChallengeInput) {
22+
// Get the challenge
23+
const challenge = await this.getLegacyChallenge({ legacyChallengeId: input.projectId })
2224
// Get the challenge phases:
2325
const { projectPhases } = await LegacyPhaseDomain.getProjectPhases({ projectId: input.projectId })
2426

@@ -141,7 +143,7 @@ class LegacyChallengeDomain {
141143

142144
// Create new reviewer using current user's id (22838965 - tcwebservice)
143145
const createResourceRes = await LegacyResourceDomain.createResource({
144-
resourceRoleId: 4,
146+
resourceRoleId: challenge.projectCategoryId === ProjectCategories.First2Finish ? ResourceRoleTypeIds.IterativeReviewer : ResourceRoleTypeIds.Reviewer,
145147
projectId: input.projectId,
146148
userId: 22838965 // TODO: get this from interceptors
147149
})
@@ -238,7 +240,7 @@ class LegacyChallengeDomain {
238240

239241
public async getLegacyChallenge(
240242
input: LegacyChallengeId
241-
): Promise<LegacyChallenge|undefined> {
243+
): Promise<LegacyChallenge> {
242244
const { rows } = await queryRunner.run(
243245
new QueryBuilder(ProjectSchema)
244246
.select(..._.map(ProjectSchema.columns))
@@ -251,7 +253,8 @@ class LegacyChallengeDomain {
251253
.limit(1)
252254
.build()
253255
);
254-
return rows?.length ? LegacyChallenge.fromPartial(rows[0] as LegacyChallenge) : undefined;
256+
if (!rows || rows.length === 0) throw new Error(`Cannot find challenge with id: ${input.legacyChallengeId}`)
257+
return LegacyChallenge.fromPartial(rows[0] as LegacyChallenge);
255258
}
256259

257260
public async checkChallengeExists(

0 commit comments

Comments
 (0)