Skip to content

Commit 234ade3

Browse files
fixes for challenge update
1 parent adcb9c4 commit 234ade3

File tree

10 files changed

+47
-407
lines changed

10 files changed

+47
-407
lines changed

src/config/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const ResourceInfoTypeIds = {
5252
ManualPayments: 15,
5353
};
5454

55-
export type ResourceInfoTypeIds = keyof typeof ResourceInfoTypeIds;
55+
type ResourceInfoTypeIds = keyof typeof ResourceInfoTypeIds;
5656

5757
export const ObserverResourceInfoToAdd: ResourceInfoTypeIds[] = [
5858
"ExternalReferenceId",

src/domain/LegacyChallenge.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ class LegacyChallengeDomain {
568568
intValue: input.legacyChallengeId,
569569
},
570570
})
571-
.limit(1)
572571
.build()
573572
);
574573
if (!rows || rows.length === 0)
@@ -587,7 +586,6 @@ class LegacyChallengeDomain {
587586
intValue: legacyChallengeId,
588587
},
589588
})
590-
.limit(1)
591589
.build();
592590

593591
const { rows } = await queryRunner.run(query);

src/domain/LegacyChallengePhase.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class LegacyChallengePhaseDomain {
2828
public async getPhaseTypes(): Promise<PhaseTypeList> {
2929
const query = new QueryBuilder(PhaseTypeSchema)
3030
.select(PhaseTypeSchema.columns.phaseTypeId, PhaseTypeSchema.columns.name)
31-
.limit(500)
3231
.build();
3332

3433
const { rows: projectPhases } = await queryRunner.run(query);

src/domain/LegacyPhase.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import { PhaseTypeSchema } from "../schema/project/PhaseType";
2424
import { ProjectPhaseSchema } from "../schema/project/ProjectPhase";
2525

2626
class LegacyPhaseDomain {
27-
public async getPhaseTypes(): Promise<PhaseTypeList | undefined> {
27+
public async getPhaseTypes(): Promise<PhaseTypeList> {
2828
const query = new QueryBuilder(PhaseTypeSchema)
29-
.select(..._.map(PhaseTypeSchema.columns))
30-
.limit(500)
29+
.select(PhaseTypeSchema.columns.name, PhaseTypeSchema.columns.phaseTypeId)
3130
.build();
3231

3332
const { rows } = await queryRunner.run(query);
@@ -49,7 +48,6 @@ class LegacyPhaseDomain {
4948
intValue: input.phaseCriteriaTypeId!,
5049
},
5150
})
52-
.limit(500)
5351
.build();
5452

5553
const { rows } = await queryRunner.run(query);

src/domain/ProjectInfo.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Operator, QueryBuilder } from "@topcoder-framework/client-relational";
2+
import { UpdateResult } from "@topcoder-framework/lib-common";
23
import { queryRunner } from "../helper/QueryRunner";
34
import {
45
CreateProjectInfoInput,
@@ -30,11 +31,11 @@ class ProjectInfoDomain {
3031
}
3132

3233
// TODO: Test this after informix-access-layer is fixed
33-
public async update(input: UpdateProjectInfoInput): Promise<ProjectInfo | undefined> {
34-
const { rows } = await queryRunner.run(
34+
public async update(input: UpdateProjectInfoInput): Promise<UpdateResult> {
35+
const res = await queryRunner.run(
3536
new QueryBuilder(ProjectInfoSchema)
3637
.update({
37-
projectId: input.projectId,
38+
value: input.value,
3839
modifyUser: input.modifyUser,
3940
})
4041
.where(ProjectInfoSchema.columns.projectId, Operator.OPERATOR_EQUAL, {
@@ -43,9 +44,17 @@ class ProjectInfoDomain {
4344
intValue: input.projectId,
4445
},
4546
})
47+
.andWhere(ProjectInfoSchema.columns.projectInfoTypeId, Operator.OPERATOR_EQUAL, {
48+
value: {
49+
$case: "intValue",
50+
intValue: input.projectInfoTypeId
51+
}
52+
})
4653
.build()
4754
);
48-
return rows?.length ? ProjectInfo.fromPartial(rows[0] as ProjectInfo) : undefined;
55+
return {
56+
updatedCount: res.affectedRows!
57+
};
4958
}
5059

5160
public async delete(input: DeleteProjectInfoInput) {
@@ -69,25 +78,29 @@ class ProjectInfoDomain {
6978
}
7079

7180
public async getProjectInfo(input: GetProjectInfoInput): Promise<ProjectInfoList> {
81+
let query = new QueryBuilder(ProjectInfoSchema)
82+
.select(
83+
ProjectInfoSchema.columns.projectId,
84+
ProjectInfoSchema.columns.projectInfoTypeId,
85+
ProjectInfoSchema.columns.value
86+
)
87+
.where(ProjectInfoSchema.columns.projectId, Operator.OPERATOR_EQUAL, {
88+
value: {
89+
$case: "intValue",
90+
intValue: input.projectId,
91+
},
92+
})
93+
if (input.projectInfoTypeId) {
94+
query = query
95+
.andWhere(ProjectInfoSchema.columns.projectInfoTypeId, Operator.OPERATOR_EQUAL, {
96+
value: {
97+
$case: "intValue",
98+
intValue: input.projectInfoTypeId!,
99+
},
100+
})
101+
}
72102
const { rows } = await queryRunner.run(
73-
new QueryBuilder(ProjectInfoSchema)
74-
.select(
75-
ProjectInfoSchema.columns.projectId,
76-
ProjectInfoSchema.columns.projectInfoTypeId,
77-
ProjectInfoSchema.columns.value
78-
)
79-
.where(ProjectInfoSchema.columns.projectId, Operator.OPERATOR_EQUAL, {
80-
value: {
81-
$case: "intValue",
82-
intValue: input.projectId,
83-
},
84-
})
85-
.andWhere(ProjectInfoSchema.columns.projectInfoTypeId, Operator.OPERATOR_EQUAL, {
86-
value: {
87-
$case: "intValue",
88-
intValue: input.projectInfoTypeId!,
89-
},
90-
})
103+
query
91104
.build()
92105
);
93106

src/domain/Review.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class LegacyReviewDomain {
9494
intValue: uploadId,
9595
},
9696
})
97-
.limit(1)
9897
.build()
9998
);
10099
if (!rows || rows?.length === 0) return undefined;

0 commit comments

Comments
 (0)