fix: deadline bug in seed data

This commit is contained in:
Joyelle Ndagijimana 2025-05-12 22:02:44 +02:00
parent 0809e1b52e
commit 968d38ca32
3 changed files with 20 additions and 15 deletions

View file

@ -1,8 +1,8 @@
import { Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Class } from '../classes/class.entity.js';
import { Group } from './group.entity.js';
import { Language } from '@dwengo-1/common/util/language';
import { AssignmentRepository } from '../../data/assignments/assignment-repository.js';
import {Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from '@mikro-orm/core';
import {Class} from '../classes/class.entity.js';
import {Group} from './group.entity.js';
import {Language} from '@dwengo-1/common/util/language';
import {AssignmentRepository} from '../../data/assignments/assignment-repository.js';
@Entity({
repository: () => AssignmentRepository,
@ -14,19 +14,19 @@ export class Assignment {
})
within!: Class;
@PrimaryKey({ type: 'integer', autoincrement: true })
@PrimaryKey({type: 'integer', autoincrement: true})
id?: number;
@Property({ type: 'string' })
@Property({type: 'string'})
title!: string;
@Property({ type: 'text' })
@Property({type: 'text'})
description!: string;
@Property({ type: 'string' })
@Property({type: 'string'})
learningPathHruid!: string;
@Property({ type: 'datetime' })
@Property({type: 'datetime'})
deadline?: Date;
@Enum({

View file

@ -5,12 +5,15 @@ import { Language } from '@dwengo-1/common/util/language';
import { testLearningPathWithConditions } from '../content/learning-paths.testdata';
import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.testdata';
const futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
const pastDate = new Date();
pastDate.setDate(pastDate.getDate() - 7);
export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] {
const futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
const pastDate = new Date();
pastDate.setDate(pastDate.getDate() - 7);
const today = new Date();
today.setHours(23, 59);
assignment01 = em.create(Assignment, {
id: 21000,
within: classes[0],
@ -18,7 +21,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign
description: 'reading',
learningPathHruid: 'un_ai',
learningPathLanguage: Language.English,
deadline: new Date(),
deadline: today,
groups: [],
});

View file

@ -101,6 +101,8 @@
day: "2-digit",
month: "long",
year: "numeric",
hour: "numeric",
minute: "2-digit",
});
}