Skip to content

Commit 8d33cec

Browse files
authored
Merge pull request #7 from topcoder-platform/fix/lint-error-path
Fix lint errors and correct path
2 parents af62e0b + d7676f5 commit 8d33cec

27 files changed

+544
-370
lines changed

prisma/migrate.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let projectCategoryMap: Record<string, ProjectTypeMap> = {};
5757
let reviewItemCommentTypeMap: Record<string, string> = {};
5858

5959
// Global submission map to store submission information.
60-
let submissionMap: Record<string, Record<string, string>> = {};
60+
const submissionMap: Record<string, Record<string, string>> = {};
6161

6262
// Data lookup maps
6363
// Initialize maps from files if they exist, otherwise create new maps
@@ -287,15 +287,15 @@ function processLookupFiles() {
287287
/**
288288
* Read submission data from resource_xxx.json, upload_xxx.json and submission_xxx.json.
289289
*/
290-
async function initSubmissionMap() {
290+
function initSubmissionMap() {
291291
// read submission_x.json, read {uploadId -> submissionId} map.
292292
const submissionRegex = new RegExp(`^submission_\\d+\\.json`);
293293
const uploadRegex = new RegExp(`^upload_\\d+\\.json`);
294294
const resourceRegex = new RegExp(`^resource_\\d+\\.json`);
295295
const submissionFiles: string[] = [];
296296
const uploadFiles: string[] = [];
297297
const resourceFiles: string[] = [];
298-
fs.readdirSync(DATA_DIR).filter(f => {
298+
fs.readdirSync(DATA_DIR).filter((f) => {
299299
if (submissionRegex.test(f)) {
300300
submissionFiles.push(f);
301301
}
@@ -313,14 +313,14 @@ async function initSubmissionMap() {
313313
const filePath = path.join(DATA_DIR, f);
314314
console.log(`Reading submission data from ${f}`);
315315
const jsonData = readJson(filePath)['submission'];
316-
for (let d of jsonData) {
316+
for (const d of jsonData) {
317317
if (d['submission_status_id'] === '1' && d['upload_id']) {
318318
submissionCount += 1;
319319
// find submission has score and most recent
320320
const item = {
321321
score: d['screening_score'] || d['initial_score'] || d['final_score'],
322322
created: d['create_date'],
323-
submissionId: d['submission_id']
323+
submissionId: d['submission_id'],
324324
};
325325
if (uploadSubmissionMap[d['upload_id']]) {
326326
// existing submission info
@@ -342,12 +342,17 @@ async function initSubmissionMap() {
342342
const filePath = path.join(DATA_DIR, f);
343343
console.log(`Reading upload data from ${f}`);
344344
const jsonData = readJson(filePath)['upload'];
345-
for (let d of jsonData) {
346-
if (d['upload_status_id'] === '1' && d['upload_type_id'] === '1' && d['resource_id']) {
345+
for (const d of jsonData) {
346+
if (
347+
d['upload_status_id'] === '1' &&
348+
d['upload_type_id'] === '1' &&
349+
d['resource_id']
350+
) {
347351
// get submission info
348-
uploadCount += 1
352+
uploadCount += 1;
349353
if (uploadSubmissionMap[d['upload_id']]) {
350-
resourceSubmissionMap[d['resource_id']] = uploadSubmissionMap[d['upload_id']];
354+
resourceSubmissionMap[d['resource_id']] =
355+
uploadSubmissionMap[d['upload_id']];
351356
}
352357
}
353358
}
@@ -361,7 +366,7 @@ async function initSubmissionMap() {
361366
const filePath = path.join(DATA_DIR, f);
362367
console.log(`Reading resource data from ${f}`);
363368
const jsonData = readJson(filePath)['resource'];
364-
for (let d of jsonData) {
369+
for (const d of jsonData) {
365370
const projectId = d['project_id'];
366371
const userId = d['user_id'];
367372
const resourceId = d['resource_id'];
@@ -387,16 +392,17 @@ async function initSubmissionMap() {
387392
}
388393
}
389394
}
390-
console.log(`Read resource count: ${resourceCount}, submission resource count: ${validResourceCount}`);
395+
console.log(
396+
`Read resource count: ${resourceCount}, submission resource count: ${validResourceCount}`,
397+
);
391398
// print summary
392399
let totalSubmissions = 0;
393-
Object.keys(submissionMap).forEach(c => {
400+
Object.keys(submissionMap).forEach((c) => {
394401
totalSubmissions += Object.keys(submissionMap[c]).length;
395402
});
396403
console.log(`Found total submissions: ${totalSubmissions}`);
397404
}
398405

399-
400406
// Process a single type: find matching files, transform them one by one, and then insert in batches.
401407
async function processType(type: string, subtype?: string) {
402408
const regex = new RegExp(`^${type}_\\d+\\.json$`);
@@ -1050,7 +1056,7 @@ async function migrate() {
10501056

10511057
// init resource-submission data
10521058
console.log('Starting resource/submission import...');
1053-
await initSubmissionMap();
1059+
initSubmissionMap();
10541060
console.log('Resource/Submission import completed.');
10551061

10561062
console.log('Starting data import...');

src/api/api.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ import { ChallengeApiService } from 'src/shared/modules/global/challenge.service
2525
ProjectResultController,
2626
ReviewOpportunityController,
2727
ReviewApplicationController,
28-
ReviewHistoryController
28+
ReviewHistoryController,
29+
],
30+
providers: [
31+
ReviewOpportunityService,
32+
ReviewApplicationService,
33+
ChallengeApiService,
2934
],
30-
providers: [ReviewOpportunityService, ReviewApplicationService, ChallengeApiService],
3135
})
3236
export class ApiModule {}

src/api/appeal/appeal.controller.ts

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { PrismaErrorService } from '../../shared/modules/global/prisma-error.ser
3838

3939
@ApiTags('Appeal')
4040
@ApiBearerAuth()
41-
@Controller('/api/appeals')
41+
@Controller('/appeals')
4242
export class AppealController {
4343
private readonly logger: LoggerService;
4444

@@ -74,7 +74,10 @@ export class AppealController {
7474
this.logger.log(`Appeal created with ID: ${data.id}`);
7575
return data as AppealResponseDto;
7676
} catch (error) {
77-
const errorResponse = this.prismaErrorService.handleError(error, 'creating appeal');
77+
const errorResponse = this.prismaErrorService.handleError(
78+
error,
79+
'creating appeal',
80+
);
7881
throw new InternalServerErrorException({
7982
message: errorResponse.message,
8083
code: errorResponse.code,
@@ -111,15 +114,18 @@ export class AppealController {
111114
this.logger.log(`Appeal updated successfully: ${appealId}`);
112115
return data as AppealResponseDto;
113116
} catch (error) {
114-
const errorResponse = this.prismaErrorService.handleError(error, `updating appeal ${appealId}`);
115-
117+
const errorResponse = this.prismaErrorService.handleError(
118+
error,
119+
`updating appeal ${appealId}`,
120+
);
121+
116122
if (errorResponse.code === 'RECORD_NOT_FOUND') {
117-
throw new NotFoundException({
118-
message: `Appeal with ID ${appealId} was not found`,
119-
code: errorResponse.code
123+
throw new NotFoundException({
124+
message: `Appeal with ID ${appealId} was not found`,
125+
code: errorResponse.code,
120126
});
121127
}
122-
128+
123129
throw new InternalServerErrorException({
124130
message: errorResponse.message,
125131
code: errorResponse.code,
@@ -147,15 +153,18 @@ export class AppealController {
147153
this.logger.log(`Appeal deleted successfully: ${appealId}`);
148154
return { message: `Appeal ${appealId} deleted successfully.` };
149155
} catch (error) {
150-
const errorResponse = this.prismaErrorService.handleError(error, `deleting appeal ${appealId}`);
151-
156+
const errorResponse = this.prismaErrorService.handleError(
157+
error,
158+
`deleting appeal ${appealId}`,
159+
);
160+
152161
if (errorResponse.code === 'RECORD_NOT_FOUND') {
153-
throw new NotFoundException({
154-
message: `Appeal with ID ${appealId} was not found`,
155-
code: errorResponse.code
162+
throw new NotFoundException({
163+
message: `Appeal with ID ${appealId} was not found`,
164+
code: errorResponse.code,
156165
});
157166
}
158-
167+
159168
throw new InternalServerErrorException({
160169
message: errorResponse.message,
161170
code: errorResponse.code,
@@ -205,15 +214,18 @@ export class AppealController {
205214
this.logger.log(`Appeal response created for appeal ID: ${appealId}`);
206215
return data.appealResponse as AppealResponseResponseDto;
207216
} catch (error) {
208-
const errorResponse = this.prismaErrorService.handleError(error, `creating response for appeal ${appealId}`);
209-
217+
const errorResponse = this.prismaErrorService.handleError(
218+
error,
219+
`creating response for appeal ${appealId}`,
220+
);
221+
210222
if (errorResponse.code === 'RECORD_NOT_FOUND') {
211-
throw new NotFoundException({
212-
message: `Appeal with ID ${appealId} was not found`,
213-
code: errorResponse.code
223+
throw new NotFoundException({
224+
message: `Appeal with ID ${appealId} was not found`,
225+
code: errorResponse.code,
214226
});
215227
}
216-
228+
217229
throw new InternalServerErrorException({
218230
message: errorResponse.message,
219231
code: errorResponse.code,
@@ -253,18 +265,23 @@ export class AppealController {
253265
where: { id: appealResponseId },
254266
data: mapAppealResponseRequestToDto(body),
255267
});
256-
this.logger.log(`Appeal response updated successfully: ${appealResponseId}`);
268+
this.logger.log(
269+
`Appeal response updated successfully: ${appealResponseId}`,
270+
);
257271
return data as AppealResponseRequestDto;
258272
} catch (error) {
259-
const errorResponse = this.prismaErrorService.handleError(error, `updating appeal response ${appealResponseId}`);
260-
273+
const errorResponse = this.prismaErrorService.handleError(
274+
error,
275+
`updating appeal response ${appealResponseId}`,
276+
);
277+
261278
if (errorResponse.code === 'RECORD_NOT_FOUND') {
262-
throw new NotFoundException({
263-
message: `Appeal response with ID ${appealResponseId} was not found`,
264-
code: errorResponse.code
279+
throw new NotFoundException({
280+
message: `Appeal response with ID ${appealResponseId} was not found`,
281+
code: errorResponse.code,
265282
});
266283
}
267-
284+
268285
throw new InternalServerErrorException({
269286
message: errorResponse.message,
270287
code: errorResponse.code,
@@ -306,18 +323,20 @@ export class AppealController {
306323
@Query('reviewId') reviewId?: string,
307324
@Query() paginationDto?: PaginationDto,
308325
): Promise<PaginatedResponse<AppealResponseDto>> {
309-
this.logger.log(`Getting appeals with filters - resourceId: ${resourceId}, challengeId: ${challengeId}, reviewId: ${reviewId}`);
310-
326+
this.logger.log(
327+
`Getting appeals with filters - resourceId: ${resourceId}, challengeId: ${challengeId}, reviewId: ${reviewId}`,
328+
);
329+
311330
const { page = 1, perPage = 10 } = paginationDto || {};
312331
const skip = (page - 1) * perPage;
313-
332+
314333
try {
315334
// Build where clause for filtering
316335
const whereClause: any = {};
317336
if (resourceId) whereClause.resourceId = resourceId;
318337
if (challengeId) whereClause.challengeId = challengeId;
319338
if (reviewId) whereClause.appealId = reviewId;
320-
339+
321340
const [appeals, totalCount] = await Promise.all([
322341
this.prisma.appealResponse.findMany({
323342
where: whereClause,
@@ -326,11 +345,13 @@ export class AppealController {
326345
}),
327346
this.prisma.appealResponse.count({
328347
where: whereClause,
329-
})
348+
}),
330349
]);
331-
332-
this.logger.log(`Found ${appeals.length} appeals (page ${page} of ${Math.ceil(totalCount / perPage)})`);
333-
350+
351+
this.logger.log(
352+
`Found ${appeals.length} appeals (page ${page} of ${Math.ceil(totalCount / perPage)})`,
353+
);
354+
334355
return {
335356
data: appeals.map((appeal) => ({
336357
...appeal,
@@ -341,10 +362,13 @@ export class AppealController {
341362
perPage,
342363
totalCount,
343364
totalPages: Math.ceil(totalCount / perPage),
344-
}
365+
},
345366
};
346367
} catch (error) {
347-
const errorResponse = this.prismaErrorService.handleError(error, 'fetching appeals');
368+
const errorResponse = this.prismaErrorService.handleError(
369+
error,
370+
'fetching appeals',
371+
);
348372
throw new InternalServerErrorException({
349373
message: errorResponse.message,
350374
code: errorResponse.code,

src/api/contact/contactRequests.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ import { PrismaService } from '../../shared/modules/global/prisma.service';
1919

2020
@ApiTags('Contact Requests')
2121
@ApiBearerAuth()
22-
@Controller('/api')
22+
@Controller('/')
2323
export class ContactRequestsController {
2424
constructor(private readonly prisma: PrismaService) {}
2525

2626
@Post('/contact-requests')
2727
@Roles(UserRole.Submitter, UserRole.Reviewer)
2828
@Scopes(Scope.CreateContactRequest)
29-
@ApiOperation({
29+
@ApiOperation({
3030
summary: 'Create a new contact request',
31-
description: 'Roles: Submitter, Reviewer | Scopes: create:contact-request'
31+
description: 'Roles: Submitter, Reviewer | Scopes: create:contact-request',
3232
})
3333
@ApiBody({ description: 'Contact request body', type: ContactRequestDto })
3434
@ApiResponse({

src/api/health-check/healthCheck.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class GetHealthCheckResponseDto {
2323
}
2424

2525
@ApiTags('Healthcheck')
26-
@Controller('/api')
26+
@Controller('/')
2727
export class HealthCheckController {
2828
constructor(private readonly prisma: PrismaService) {}
2929

0 commit comments

Comments
 (0)