style: fix linting issues met Prettier
This commit is contained in:
parent
e78849f568
commit
400a955850
40 changed files with 321 additions and 700 deletions
|
@ -1,26 +1,12 @@
|
|||
import {
|
||||
getClassRepository,
|
||||
getStudentRepository,
|
||||
getTeacherInvitationRepository,
|
||||
getTeacherRepository,
|
||||
} from '../data/repositories.js';
|
||||
import { getClassRepository, getStudentRepository, getTeacherInvitationRepository, getTeacherRepository } from '../data/repositories.js';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
|
||||
import {
|
||||
mapToTeacherInvitationDTO,
|
||||
mapToTeacherInvitationDTOIds,
|
||||
TeacherInvitationDTO,
|
||||
} from '../interfaces/teacher-invitation.js';
|
||||
import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js';
|
||||
|
||||
export async function getAllClasses(
|
||||
full: boolean
|
||||
): Promise<ClassDTO[] | string[]> {
|
||||
export async function getAllClasses(full: boolean): Promise<ClassDTO[] | string[]> {
|
||||
const classRepository = getClassRepository();
|
||||
const classes = await classRepository.find(
|
||||
{},
|
||||
{ populate: ['students', 'teachers'] }
|
||||
);
|
||||
const classes = await classRepository.find({}, { populate: ['students', 'teachers'] });
|
||||
|
||||
if (!classes) {
|
||||
return [];
|
||||
|
@ -35,13 +21,11 @@ export async function getAllClasses(
|
|||
export async function createClass(classData: ClassDTO): Promise<Class | null> {
|
||||
const teacherRepository = getTeacherRepository();
|
||||
const teacherUsernames = classData.teachers || [];
|
||||
const teachers = (await Promise.all(teacherUsernames.map(id => teacherRepository.findByUsername(id))))
|
||||
.filter(teacher => teacher != null);
|
||||
const teachers = (await Promise.all(teacherUsernames.map((id) => teacherRepository.findByUsername(id)))).filter((teacher) => teacher != null);
|
||||
|
||||
const studentRepository = getStudentRepository();
|
||||
const studentUsernames = classData.students || [];
|
||||
const students = (await Promise.all(studentUsernames.map(id => studentRepository.findByUsername(id))))
|
||||
.filter(student => student != null);
|
||||
const students = (await Promise.all(studentUsernames.map((id) => studentRepository.findByUsername(id)))).filter((student) => student != null);
|
||||
|
||||
//Const cls = mapToClass(classData, teachers, students);
|
||||
|
||||
|
@ -56,7 +40,7 @@ export async function createClass(classData: ClassDTO): Promise<Class | null> {
|
|||
await classRepository.save(newClass);
|
||||
|
||||
return newClass;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -92,10 +76,7 @@ export async function getClassStudentsIds(classId: string): Promise<string[]> {
|
|||
return students.map((student) => student.username);
|
||||
}
|
||||
|
||||
export async function getClassTeacherInvitations(
|
||||
classId: string,
|
||||
full: boolean
|
||||
): Promise<TeacherInvitationDTO[]> {
|
||||
export async function getClassTeacherInvitations(classId: string, full: boolean): Promise<TeacherInvitationDTO[]> {
|
||||
const classRepository = getClassRepository();
|
||||
const cls = await classRepository.findById(classId);
|
||||
|
||||
|
@ -104,8 +85,7 @@ export async function getClassTeacherInvitations(
|
|||
}
|
||||
|
||||
const teacherInvitationRepository = getTeacherInvitationRepository();
|
||||
const invitations =
|
||||
await teacherInvitationRepository.findAllInvitationsForClass(cls);
|
||||
const invitations = await teacherInvitationRepository.findAllInvitationsForClass(cls);
|
||||
|
||||
if (full) {
|
||||
return invitations.map(mapToTeacherInvitationDTO);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue