fix: deadline bug in seed data
This commit is contained in:
		
							parent
							
								
									0809e1b52e
								
							
						
					
					
						commit
						968d38ca32
					
				
					 3 changed files with 20 additions and 15 deletions
				
			
		|  | @ -1,8 +1,8 @@ | ||||||
| import { Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; | import {Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from '@mikro-orm/core'; | ||||||
| import { Class } from '../classes/class.entity.js'; | import {Class} from '../classes/class.entity.js'; | ||||||
| import { Group } from './group.entity.js'; | import {Group} from './group.entity.js'; | ||||||
| import { Language } from '@dwengo-1/common/util/language'; | import {Language} from '@dwengo-1/common/util/language'; | ||||||
| import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; | import {AssignmentRepository} from '../../data/assignments/assignment-repository.js'; | ||||||
| 
 | 
 | ||||||
| @Entity({ | @Entity({ | ||||||
|     repository: () => AssignmentRepository, |     repository: () => AssignmentRepository, | ||||||
|  | @ -14,19 +14,19 @@ export class Assignment { | ||||||
|     }) |     }) | ||||||
|     within!: Class; |     within!: Class; | ||||||
| 
 | 
 | ||||||
|     @PrimaryKey({ type: 'integer', autoincrement: true }) |     @PrimaryKey({type: 'integer', autoincrement: true}) | ||||||
|     id?: number; |     id?: number; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'string' }) |     @Property({type: 'string'}) | ||||||
|     title!: string; |     title!: string; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'text' }) |     @Property({type: 'text'}) | ||||||
|     description!: string; |     description!: string; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'string' }) |     @Property({type: 'string'}) | ||||||
|     learningPathHruid!: string; |     learningPathHruid!: string; | ||||||
| 
 | 
 | ||||||
|     @Property({ type: 'datetime' }) |     @Property({type: 'datetime'}) | ||||||
|     deadline?: Date; |     deadline?: Date; | ||||||
| 
 | 
 | ||||||
|     @Enum({ |     @Enum({ | ||||||
|  |  | ||||||
|  | @ -5,12 +5,15 @@ import { Language } from '@dwengo-1/common/util/language'; | ||||||
| import { testLearningPathWithConditions } from '../content/learning-paths.testdata'; | import { testLearningPathWithConditions } from '../content/learning-paths.testdata'; | ||||||
| import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.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[] { | 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, { |     assignment01 = em.create(Assignment, { | ||||||
|         id: 21000, |         id: 21000, | ||||||
|         within: classes[0], |         within: classes[0], | ||||||
|  | @ -18,7 +21,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign | ||||||
|         description: 'reading', |         description: 'reading', | ||||||
|         learningPathHruid: 'un_ai', |         learningPathHruid: 'un_ai', | ||||||
|         learningPathLanguage: Language.English, |         learningPathLanguage: Language.English, | ||||||
|         deadline: new Date(), |         deadline: today, | ||||||
|         groups: [], |         groups: [], | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -101,6 +101,8 @@ | ||||||
|             day: "2-digit", |             day: "2-digit", | ||||||
|             month: "long", |             month: "long", | ||||||
|             year: "numeric", |             year: "numeric", | ||||||
|  |             hour: "numeric", | ||||||
|  |             minute: "2-digit", | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Joyelle Ndagijimana
						Joyelle Ndagijimana