Passed
Pull Request — master (#75)
by Mathieu
02:33 queued 01:09
created

server/src/Domain/FairCalendar/Event.entity.ts   A

Complexity

Total Complexity 8
Complexity/F 1

Size

Lines of Code 96
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 82
mnd 0
bc 0
fnc 8
dl 0
loc 96
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

8 Functions

Rating   Name   Duplication   Size   Complexity  
A Event.getId 0 3 1
A Event.getDate 0 3 1
A Event.getType 0 3 1
A Event.getSummary 0 3 1
A Event.getTask 0 3 1
A Event.getUser 0 3 1
A Event.getProject 0 3 1
A Event.getTime 0 3 1
1
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from 'typeorm';
2
import {User} from '../User/User.entity';
3
import {Task} from '../Task/Task.entity';
4
import {Project} from '../Project/Project.entity';
5
6
export enum EventType {
7
  MISSION = 'mission',
8
  SUPPORT = 'support',
9
  DOJO = 'dojo',
10
  HOLIDAY = 'holiday',
11
  FORMATION_CONFERENCE = 'formationConference',
12
  WORK_FREE = 'workFree',
13
  MEDICAL_LEAVE = 'medicalLeave',
14
  OTHER = 'other'
15
}
16
17
@Entity()
18
export class Event {
19
  // Times spent are stored in base 100
20
  public static readonly MAXIMUM_TIMESPENT_PER_DAY: number = 100;
21
22
  @PrimaryGeneratedColumn('uuid')
23
  private id: string;
24
25
  @Column('enum', {enum: EventType, nullable: false})
26
  private type: EventType;
27
28
  @Column({type: 'integer', nullable: false})
29
  private time: number;
30
31
  @Column({type: 'date', nullable: false})
32
  private date: string;
33
34
  @Column({type: 'varchar', nullable: true})
35
  private summary: string;
36
37
  @ManyToOne(type => Project, {nullable: true})
38
  private project: Project;
39
40
  @ManyToOne(type => Task, {nullable: true})
41
  private task: Task;
42
43
  @ManyToOne(type => User, {nullable: false})
44
  private user: User;
45
46
  constructor(
47
    type: EventType,
48
    user: User,
49
    time: number,
50
    date: string,
51
    project?: Project,
52
    task?: Task,
53
    summary?: string
54
  ) {
55
    this.type = type;
56
    this.user = user;
57
    this.time = time;
58
    this.date = date;
59
    this.project = project;
60
    this.task = task;
61
    this.summary = summary;
62
  }
63
64
  public getId(): string {
65
    return this.id;
66
  }
67
68
  public getType(): string {
69
    return this.type;
70
  }
71
72
  public getTime(): number {
73
    return this.time;
74
  }
75
76
  public getDate(): string {
77
    return this.date;
78
  }
79
80
  public getSummary(): string | null {
81
    return this.summary;
82
  }
83
84
  public getProject(): Project | null {
85
    return this.project;
86
  }
87
88
  public getTask(): Task | null {
89
    return this.task;
90
  }
91
92
  public getUser(): User {
93
    return this.user;
94
  }
95
}
96