refactor(backend): Linting
This commit is contained in:
		
							parent
							
								
									7155d7d893
								
							
						
					
					
						commit
						4928c08f62
					
				
					 7 changed files with 13 additions and 28 deletions
				
			
		|  | @ -66,7 +66,7 @@ export async function putAssignmentHandler(req: Request, res: Response): Promise | |||
|     res.json({ assignment }); | ||||
| } | ||||
| 
 | ||||
| export async function deleteAssignmentHandler(req: Request, res: Response): Promise<void> { | ||||
| export async function deleteAssignmentHandler(req: Request, _res: Response): Promise<void> { | ||||
|     const id = Number(req.params.id); | ||||
|     const classid = req.params.classid; | ||||
|     requireFields({ id, classid }); | ||||
|  | @ -75,7 +75,7 @@ export async function deleteAssignmentHandler(req: Request, res: Response): Prom | |||
|         throw new BadRequestException('Assignment id should be a number'); | ||||
|     } | ||||
| 
 | ||||
|     const assignment = await deleteAssignment(classid, id); | ||||
|     await deleteAssignment(classid, id); | ||||
| } | ||||
| 
 | ||||
| export async function getAssignmentsSubmissionsHandler(req: Request, res: Response): Promise<void> { | ||||
|  |  | |||
|  | @ -3,11 +3,10 @@ import { createGroup, deleteGroup, getAllGroups, getGroup, getGroupSubmissions, | |||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| import { requireFields } from './error-helper.js'; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { EntityDTO } from '@mikro-orm/core'; | ||||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| 
 | ||||
| function checkGroupFields(classId: any, assignmentId: any, groupId: any) { | ||||
| function checkGroupFields(classId: string, assignmentId: number, groupId: number): void { | ||||
|     requireFields({ classId, assignmentId, groupId }); | ||||
| 
 | ||||
|     if (isNaN(assignmentId)) { | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { createSubmission, deleteSubmission, getAllSubmissions, getSubmission } from '../services/submissions.js'; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; | ||||
| import { Language, languageMap } from '@dwengo-1/common/util/language'; | ||||
| import { SubmissionDTO } from '@dwengo-1/common/interfaces/submission'; | ||||
|  |  | |||
|  | @ -4,7 +4,6 @@ import { Assignment } from '../entities/assignments/assignment.entity.js'; | |||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { mapToGroupDTO } from './group.js'; | ||||
| 
 | ||||
| export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -14,9 +14,7 @@ import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submissi | |||
| import { fetchClass } from './classes.js'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { EntityData, EntityDTO, FromEntityType } from '@mikro-orm/core'; | ||||
| import { DwengoEntityRepository } from '../data/dwengo-entity-repository.js'; | ||||
| import { EntityDTO } from '@mikro-orm/core'; | ||||
| import { putObject } from './service-helper.js'; | ||||
| 
 | ||||
| export async function fetchAssignment(classid: string, assignmentNumber: number): Promise<Assignment> { | ||||
|  | @ -24,7 +22,7 @@ export async function fetchAssignment(classid: string, assignmentNumber: number) | |||
|     const cls = await classRepository.findById(classid); | ||||
| 
 | ||||
|     if (!cls) { | ||||
|         throw new NotFoundException("Could not find assignment's class"); | ||||
|         throw new NotFoundException('Could not find assignment\'s class'); | ||||
|     } | ||||
| 
 | ||||
|     const assignmentRepository = getAssignmentRepository(); | ||||
|  | @ -88,7 +86,7 @@ export async function deleteAssignment(classid: string, id: number): Promise<Ass | |||
| export async function getAssignmentsSubmissions( | ||||
|     classid: string, | ||||
|     assignmentNumber: number, | ||||
|     full: boolean | ||||
|     full: boolean, | ||||
| ): Promise<SubmissionDTO[] | SubmissionDTOId[]> { | ||||
|     const assignment = await fetchAssignment(classid, assignmentNumber); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,21 +1,12 @@ | |||
| import { assign, EntityDTO } from '@mikro-orm/core'; | ||||
| import { | ||||
|     getAssignmentRepository, | ||||
|     getClassRepository, | ||||
|     getGroupRepository, | ||||
|     getQuestionRepository, | ||||
|     getStudentRepository, | ||||
|     getSubmissionRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { EntityDTO } from '@mikro-orm/core'; | ||||
| import { getGroupRepository, getStudentRepository, getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { fetchAssignment } from './assignments.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { fetchClass } from './classes.js'; | ||||
| import { putObject } from './service-helper.js'; | ||||
| 
 | ||||
| export async function fetchGroup(classId: string, assignmentNumber: number, groupNumber: number): Promise<Group> { | ||||
|  | @ -40,7 +31,7 @@ export async function putGroup( | |||
|     classId: string, | ||||
|     assignmentNumber: number, | ||||
|     groupNumber: number, | ||||
|     groupData: Partial<EntityDTO<Group>> | ||||
|     groupData: Partial<EntityDTO<Group>>, | ||||
| ): Promise<GroupDTO> { | ||||
|     const group = await fetchGroup(classId, assignmentNumber, groupNumber); | ||||
| 
 | ||||
|  | @ -59,7 +50,7 @@ export async function deleteGroup(classId: string, assignmentNumber: number, gro | |||
|     return mapToGroupDTO(group); | ||||
| } | ||||
| 
 | ||||
| export async function getExistingGroupFromGroupDTO(groupData: GroupDTO) { | ||||
| export async function getExistingGroupFromGroupDTO(groupData: GroupDTO): Promise<Group> { | ||||
|     const classId = typeof groupData.class === 'string' ? groupData.class : groupData.class.id; | ||||
|     const assignmentNumber = typeof groupData.assignment === 'number' ? groupData.assignment : groupData.assignment.id; | ||||
|     const groupNumber = groupData.groupNumber; | ||||
|  | @ -72,7 +63,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme | |||
| 
 | ||||
|     const memberUsernames = (groupData.members as string[]) || []; | ||||
|     const members = (await Promise.all([...memberUsernames].map(async (id) => studentRepository.findByUsername(id)))).filter( | ||||
|         (student) => student !== null | ||||
|         (student) => student !== null, | ||||
|     ); | ||||
| 
 | ||||
|     const assignment = await fetchAssignment(classid, assignmentNumber); | ||||
|  | @ -104,7 +95,7 @@ export async function getGroupSubmissions( | |||
|     classId: string, | ||||
|     assignmentNumber: number, | ||||
|     groupNumber: number, | ||||
|     full: boolean | ||||
|     full: boolean, | ||||
| ): Promise<SubmissionDTO[] | SubmissionDTOId[]> { | ||||
|     const group = await fetchGroup(classId, assignmentNumber, groupNumber); | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,8 @@ import { LearningObjectIdentifier } from '../entities/content/learning-object-id | |||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { mapToSubmission, mapToSubmissionDTO } from '../interfaces/submission.js'; | ||||
| import { SubmissionDTO } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { fetchStudent } from './students.js'; | ||||
| import { fetchGroup, getExistingGroupFromGroupDTO } from './groups.js'; | ||||
| import { getExistingGroupFromGroupDTO } from './groups.js'; | ||||
| import { Submission } from '../entities/assignments/submission.entity.js'; | ||||
| 
 | ||||
| export async function fetchSubmission(loId: LearningObjectIdentifier, submissionNumber: number): Promise<Submission> { | ||||
|  |  | |||
		Reference in a new issue