fix: lint proberen fixen

This commit is contained in:
Joyelle Ndagijimana 2025-05-18 13:06:25 +02:00
parent 844dce839f
commit 9af2f136eb
3 changed files with 20 additions and 21 deletions

View file

@ -1,6 +1,5 @@
import { EntityRepository, FilterQuery } from '@mikro-orm/core';
import { EntityAlreadyExistsException } from '../exceptions/entity-already-exists-exception.js';
import { getLogger } from '../logging/initalize.js';
export abstract class DwengoEntityRepository<T extends object> extends EntityRepository<T> {
public async save(entity: T, options?: { preventOverwrite?: boolean }): Promise<void> {

View file

@ -18,7 +18,6 @@ import { EntityDTO } from '@mikro-orm/core';
import {putObject} from './service-helper.js';
import {fetchStudents} from './students.js';
import {ServerErrorException} from '../exceptions/server-error-exception.js';
import { createGroup, deleteGroup, fetchAllGroups } from './groups.js';
import {BadRequestException} from '../exceptions/bad-request-exception.js';
export async function fetchAssignment(classid: string, assignmentNumber: number): Promise<Assignment> {
@ -45,8 +44,6 @@ export async function getAllAssignments(classid: string, full: boolean): Promise
const assignmentRepository = getAssignmentRepository();
const assignments = await assignmentRepository.findAllAssignmentsInClass(cls);
console.log(assignments);
if (full) {
return assignments.map(mapToAssignmentDTO);
}
@ -97,11 +94,14 @@ export async function getAssignment(classid: string, id: number): Promise<Assign
return mapToAssignmentDTO(assignment);
}
function hasDuplicates(arr: string[]): boolean {
return new Set(arr).size !== arr.length;
}
export async function putAssignment(classid: string, id: number, assignmentData: Partial<AssignmentDTO>): Promise<AssignmentDTO> {
const assignment = await fetchAssignment(classid, id);
if (assignmentData.groups) {
const hasDuplicates = (arr: string[]) => new Set(arr).size !== arr.length;
if (hasDuplicates(assignmentData.groups.flat() as string[])) {
throw new BadRequestException('Student can only be in one group');
}

View file

@ -12,7 +12,7 @@ import type { ClassesResponse } from "@/controllers/classes.ts";
import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts";
import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher";
import { studentJoinRequestQueryKey, studentJoinRequestsQueryKey } from "@/queries/students.ts";
import type { AssignmentResponse, AssignmentsResponse } from "@/controllers/assignments";
import type { AssignmentsResponse } from "@/controllers/assignments";
const teacherController = new TeacherController();