-
Notifications
You must be signed in to change notification settings - Fork 5
Fix lint errors and correct path #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ let projectCategoryMap: Record<string, ProjectTypeMap> = {}; | |
let reviewItemCommentTypeMap: Record<string, string> = {}; | ||
|
||
// Global submission map to store submission information. | ||
let submissionMap: Record<string, Record<string, string>> = {}; | ||
const submissionMap: Record<string, Record<string, string>> = {}; | ||
|
||
// Data lookup maps | ||
// Initialize maps from files if they exist, otherwise create new maps | ||
|
@@ -287,15 +287,15 @@ function processLookupFiles() { | |
/** | ||
* Read submission data from resource_xxx.json, upload_xxx.json and submission_xxx.json. | ||
*/ | ||
async function initSubmissionMap() { | ||
function initSubmissionMap() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function |
||
// read submission_x.json, read {uploadId -> submissionId} map. | ||
const submissionRegex = new RegExp(`^submission_\\d+\\.json`); | ||
const uploadRegex = new RegExp(`^upload_\\d+\\.json`); | ||
const resourceRegex = new RegExp(`^resource_\\d+\\.json`); | ||
const submissionFiles: string[] = []; | ||
const uploadFiles: string[] = []; | ||
const resourceFiles: string[] = []; | ||
fs.readdirSync(DATA_DIR).filter(f => { | ||
fs.readdirSync(DATA_DIR).filter((f) => { | ||
if (submissionRegex.test(f)) { | ||
submissionFiles.push(f); | ||
} | ||
|
@@ -313,14 +313,14 @@ async function initSubmissionMap() { | |
const filePath = path.join(DATA_DIR, f); | ||
console.log(`Reading submission data from ${f}`); | ||
const jsonData = readJson(filePath)['submission']; | ||
for (let d of jsonData) { | ||
for (const d of jsonData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
if (d['submission_status_id'] === '1' && d['upload_id']) { | ||
submissionCount += 1; | ||
// find submission has score and most recent | ||
const item = { | ||
score: d['screening_score'] || d['initial_score'] || d['final_score'], | ||
created: d['create_date'], | ||
submissionId: d['submission_id'] | ||
submissionId: d['submission_id'], | ||
}; | ||
if (uploadSubmissionMap[d['upload_id']]) { | ||
// existing submission info | ||
|
@@ -342,12 +342,17 @@ async function initSubmissionMap() { | |
const filePath = path.join(DATA_DIR, f); | ||
console.log(`Reading upload data from ${f}`); | ||
const jsonData = readJson(filePath)['upload']; | ||
for (let d of jsonData) { | ||
if (d['upload_status_id'] === '1' && d['upload_type_id'] === '1' && d['resource_id']) { | ||
for (const d of jsonData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
if ( | ||
d['upload_status_id'] === '1' && | ||
d['upload_type_id'] === '1' && | ||
d['resource_id'] | ||
) { | ||
// get submission info | ||
uploadCount += 1 | ||
uploadCount += 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent use of semicolons throughout the code. A semicolon was added here, so verify other parts of the code for consistency. |
||
if (uploadSubmissionMap[d['upload_id']]) { | ||
resourceSubmissionMap[d['resource_id']] = uploadSubmissionMap[d['upload_id']]; | ||
resourceSubmissionMap[d['resource_id']] = | ||
uploadSubmissionMap[d['upload_id']]; | ||
} | ||
} | ||
} | ||
|
@@ -361,7 +366,7 @@ async function initSubmissionMap() { | |
const filePath = path.join(DATA_DIR, f); | ||
console.log(`Reading resource data from ${f}`); | ||
const jsonData = readJson(filePath)['resource']; | ||
for (let d of jsonData) { | ||
for (const d of jsonData) { | ||
const projectId = d['project_id']; | ||
const userId = d['user_id']; | ||
const resourceId = d['resource_id']; | ||
|
@@ -387,16 +392,17 @@ async function initSubmissionMap() { | |
} | ||
} | ||
} | ||
console.log(`Read resource count: ${resourceCount}, submission resource count: ${validResourceCount}`); | ||
console.log( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The console.log statement has been split into multiple lines. Consider keeping it on a single line for better readability unless it exceeds the maximum line length. |
||
`Read resource count: ${resourceCount}, submission resource count: ${validResourceCount}`, | ||
); | ||
// print summary | ||
let totalSubmissions = 0; | ||
Object.keys(submissionMap).forEach(c => { | ||
Object.keys(submissionMap).forEach((c) => { | ||
totalSubmissions += Object.keys(submissionMap[c]).length; | ||
}); | ||
console.log(`Found total submissions: ${totalSubmissions}`); | ||
} | ||
|
||
|
||
// Process a single type: find matching files, transform them one by one, and then insert in batches. | ||
async function processType(type: string, subtype?: string) { | ||
const regex = new RegExp(`^${type}_\\d+\\.json$`); | ||
|
@@ -1050,7 +1056,7 @@ async function migrate() { | |
|
||
// init resource-submission data | ||
console.log('Starting resource/submission import...'); | ||
await initSubmissionMap(); | ||
initSubmissionMap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
console.log('Resource/Submission import completed.'); | ||
|
||
console.log('Starting data import...'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ import { PrismaErrorService } from '../../shared/modules/global/prisma-error.ser | |
|
||
@ApiTags('Appeal') | ||
@ApiBearerAuth() | ||
@Controller('/api/appeals') | ||
@Controller('/appeals') | ||
export class AppealController { | ||
private readonly logger: LoggerService; | ||
|
||
|
@@ -74,7 +74,10 @@ export class AppealController { | |
this.logger.log(`Appeal created with ID: ${data.id}`); | ||
return data as AppealResponseDto; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, 'creating appeal'); | ||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
'creating appeal', | ||
); | ||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
@@ -111,15 +114,18 @@ export class AppealController { | |
this.logger.log(`Appeal updated successfully: ${appealId}`); | ||
return data as AppealResponseDto; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, `updating appeal ${appealId}`); | ||
|
||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
`updating appeal ${appealId}`, | ||
); | ||
|
||
if (errorResponse.code === 'RECORD_NOT_FOUND') { | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code, | ||
}); | ||
} | ||
|
||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
@@ -147,15 +153,18 @@ export class AppealController { | |
this.logger.log(`Appeal deleted successfully: ${appealId}`); | ||
return { message: `Appeal ${appealId} deleted successfully.` }; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, `deleting appeal ${appealId}`); | ||
|
||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
`deleting appeal ${appealId}`, | ||
); | ||
|
||
if (errorResponse.code === 'RECORD_NOT_FOUND') { | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing comma is unnecessary in the object literal. Consider removing it for consistency with the rest of the code style. |
||
}); | ||
} | ||
|
||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
@@ -205,15 +214,18 @@ export class AppealController { | |
this.logger.log(`Appeal response created for appeal ID: ${appealId}`); | ||
return data.appealResponse as AppealResponseResponseDto; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, `creating response for appeal ${appealId}`); | ||
|
||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
`creating response for appeal ${appealId}`, | ||
); | ||
|
||
if (errorResponse.code === 'RECORD_NOT_FOUND') { | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code | ||
throw new NotFoundException({ | ||
message: `Appeal with ID ${appealId} was not found`, | ||
code: errorResponse.code, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider removing the trailing comma after |
||
}); | ||
} | ||
|
||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
@@ -253,18 +265,23 @@ export class AppealController { | |
where: { id: appealResponseId }, | ||
data: mapAppealResponseRequestToDto(body), | ||
}); | ||
this.logger.log(`Appeal response updated successfully: ${appealResponseId}`); | ||
this.logger.log( | ||
`Appeal response updated successfully: ${appealResponseId}`, | ||
); | ||
return data as AppealResponseRequestDto; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, `updating appeal response ${appealResponseId}`); | ||
|
||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
`updating appeal response ${appealResponseId}`, | ||
); | ||
|
||
if (errorResponse.code === 'RECORD_NOT_FOUND') { | ||
throw new NotFoundException({ | ||
message: `Appeal response with ID ${appealResponseId} was not found`, | ||
code: errorResponse.code | ||
throw new NotFoundException({ | ||
message: `Appeal response with ID ${appealResponseId} was not found`, | ||
code: errorResponse.code, | ||
}); | ||
} | ||
|
||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
@@ -306,18 +323,20 @@ export class AppealController { | |
@Query('reviewId') reviewId?: string, | ||
@Query() paginationDto?: PaginationDto, | ||
): Promise<PaginatedResponse<AppealResponseDto>> { | ||
this.logger.log(`Getting appeals with filters - resourceId: ${resourceId}, challengeId: ${challengeId}, reviewId: ${reviewId}`); | ||
|
||
this.logger.log( | ||
`Getting appeals with filters - resourceId: ${resourceId}, challengeId: ${challengeId}, reviewId: ${reviewId}`, | ||
); | ||
|
||
const { page = 1, perPage = 10 } = paginationDto || {}; | ||
const skip = (page - 1) * perPage; | ||
|
||
try { | ||
// Build where clause for filtering | ||
const whereClause: any = {}; | ||
if (resourceId) whereClause.resourceId = resourceId; | ||
if (challengeId) whereClause.challengeId = challengeId; | ||
if (reviewId) whereClause.appealId = reviewId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition |
||
|
||
const [appeals, totalCount] = await Promise.all([ | ||
this.prisma.appealResponse.findMany({ | ||
where: whereClause, | ||
|
@@ -326,11 +345,13 @@ export class AppealController { | |
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation of the closing bracket on line 345 should match the opening bracket on line 326 for better readability. |
||
this.prisma.appealResponse.count({ | ||
where: whereClause, | ||
}) | ||
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation of the closing bracket on line 348 should match the opening bracket on line 346 for consistency. |
||
]); | ||
|
||
this.logger.log(`Found ${appeals.length} appeals (page ${page} of ${Math.ceil(totalCount / perPage)})`); | ||
|
||
|
||
this.logger.log( | ||
`Found ${appeals.length} appeals (page ${page} of ${Math.ceil(totalCount / perPage)})`, | ||
); | ||
|
||
return { | ||
data: appeals.map((appeal) => ({ | ||
...appeal, | ||
|
@@ -341,10 +362,13 @@ export class AppealController { | |
perPage, | ||
totalCount, | ||
totalPages: Math.ceil(totalCount / perPage), | ||
} | ||
}, | ||
}; | ||
} catch (error) { | ||
const errorResponse = this.prismaErrorService.handleError(error, 'fetching appeals'); | ||
const errorResponse = this.prismaErrorService.handleError( | ||
error, | ||
'fetching appeals', | ||
); | ||
throw new InternalServerErrorException({ | ||
message: errorResponse.message, | ||
code: errorResponse.code, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,16 +19,16 @@ import { PrismaService } from '../../shared/modules/global/prisma.service'; | |
|
||
@ApiTags('Contact Requests') | ||
@ApiBearerAuth() | ||
@Controller('/api') | ||
@Controller('/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the controller path from |
||
export class ContactRequestsController { | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
@Post('/contact-requests') | ||
@Roles(UserRole.Submitter, UserRole.Reviewer) | ||
@Scopes(Scope.CreateContactRequest) | ||
@ApiOperation({ | ||
@ApiOperation({ | ||
summary: 'Create a new contact request', | ||
description: 'Roles: Submitter, Reviewer | Scopes: create:contact-request' | ||
description: 'Roles: Submitter, Reviewer | Scopes: create:contact-request', | ||
}) | ||
@ApiBody({ description: 'Contact request body', type: ContactRequestDto }) | ||
@ApiResponse({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ export class GetHealthCheckResponseDto { | |
} | ||
|
||
@ApiTags('Healthcheck') | ||
@Controller('/api') | ||
@Controller('/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from |
||
export class HealthCheckController { | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider reviewing other variables in the file to ensure consistent use of
const
where appropriate. Changinglet
toconst
is a good practice when the variable is not reassigned, but consistency across similar variables can improve readability and maintainability.