File size: 1,081 Bytes
e67d35c
 
 
 
 
 
 
 
9f03bd9
 
 
e67d35c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f03bd9
e67d35c
9f03bd9
e67d35c
9f03bd9
e67d35c
9f03bd9
e67d35c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
  CreateDateColumn,
} from 'typeorm';
import type { Relation } from 'typeorm';
import type { User } from '../../auth/entities/user.entity';
import type { StudentTask } from './student-task.entity';

@Entity('task_completion')
export class TaskCompletion {
  @PrimaryGeneratedColumn({ name: 'completion_id', type: 'bigint', unsigned: true })
  completionId: number;

  @Column({ name: 'task_id', type: 'bigint', unsigned: true, unique: true })
  taskId: number;

  @Column({ name: 'user_id', type: 'bigint', unsigned: true })
  userId: number;

  @CreateDateColumn({ name: 'completed_at', type: 'timestamp' })
  completedAt: Date;

  @Column({ name: 'time_taken_minutes', type: 'int', nullable: true })
  timeTakenMinutes: number | null;

  @Column({ name: 'notes', type: 'text', nullable: true })
  notes: string | null;

  @ManyToOne('StudentTask')
  @JoinColumn({ name: 'task_id' })
  task: Relation<StudentTask>;

  @ManyToOne('User')
  @JoinColumn({ name: 'user_id' })
  user: Relation<User>;
}