Passed
Push — task/ide-helper ( 159489...25c04b )
by Grant
08:53 queued 10s
created

lookupConstants.ts ➔ getKeyByValue   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
1
export enum ReviewStatusId {
2
  ScreenedOut = 1,
3
  StillThinking = 2,
4
  StillIn = 3,
5
}
6
7
export type ReviewStatusName = "screened_out" | "still_thinking" | "still_in";
8
9
export enum CriteriaTypeId {
10
  Essential = 1,
11
  Asset = 2,
12
}
13
14
export enum SkillTypeId {
15
  Soft = 1,
16
  Hard = 2,
17
}
18
19
export enum SkillLevelId {
20
  Basic = 1,
21
  Intermediate = 2,
22
  Advanced = 3,
23
  Expert = 4,
24
}
25
26
export enum AssessmentTypeId {
27
  NarrativeAssessment = 1,
28
  ApplicationScreeningQuestion = 2,
29
  GroupTest = 3,
30
  InformalPhoneConversation = 4,
31
  Interview = 5,
32
  OnlineExam = 6,
33
  OnSiteExam = 7,
34
  TakeHomeExam = 8,
35
  PortfolioReview = 9,
36
  ReferenceCheck = 10,
37
  SeriousGames = 11,
38
}
39
40
export const ProvinceId = {
41
  AB: 1,
42
  BC: 2,
43
  MB: 3,
44
  NL: 4,
45
  NB: 5,
46
  NS: 6,
47
  NU: 7,
48
  NT: 8,
49
  ON: 9,
50
  PE: 10,
51
  QC: 11,
52
  SK: 12,
53
  YT: 13,
54
};
55
56
export const SecurityClearanceId = {
57
  reliability: 1,
58
  secret: 2,
59
  topSecret: 3,
60
};
61
62
export const LanguageRequirementId = {
63
  english: 1,
64
  french: 2,
65
  bilingualIntermediate: 3,
66
  bilingualAdvanced: 4,
67
  englishOrFrench: 5,
68
};
69
70
export const DepartmentId = {
71
  treasuryBoard: 1,
72
  naturalResources: 2,
73
  transport: 3,
74
  environmentAndClimateChange: 4,
75
  employmentAndSocialDevelopment: 5,
76
  globalAffairs: 6,
77
  borderServices: 7,
78
  fisheriesAndOceans: 8,
79
  innovationScience: 9,
80
  publicServiceAndProcurement: 10,
81
  nationalDefence: 11,
82
};
83
84
export const FrequencyId = {
85
  never: 1,
86
  rarely: 2,
87
  sometimes: 3,
88
  often: 4,
89
  always: 5,
90
};
91
92
export const TravelRequirementId = {
93
  frequently: 1,
94
  available: 2,
95
  none: 3,
96
};
97
98
export const OvertimeRequirementId = {
99
  frequently: 1,
100
  available: 2,
101
  none: 3,
102
};
103
104
export const ClassificationId = {
105
  AS: 1,
106
  BI: 2,
107
  CO: 3,
108
  CR: 4,
109
  CS: 5,
110
  EC: 6,
111
  EX: 7,
112
  FO: 8,
113
  IS: 9,
114
  PC: 10,
115
  PE: 11,
116
  PM: 12,
117
  AD: 13,
118
};
119
120
export function getKeyByValue(object, value): string {
121
  return (
122
    Object.keys(object).find(key => object[key] === parseInt(value, 10)) || ""
123
  );
124
}
125
126
export function enumToIds(enumType: object): number[] {
127
  const enumVals = Object.values(enumType);
128
  // Note: this first array includes the list of ids as strings, followed by the list of names as strings
129
  const enumIds = enumVals.filter(item => !Number.isNaN(Number(item)));
130
  return enumIds.map(id => Number(id));
131
}
132
133
export const SkillLevelIdValues = enumToIds(SkillLevelId);
134
135
export const SkillTypeIdValues = enumToIds(SkillTypeId);
136
137
export const AssessmentTypeIdValues = enumToIds(AssessmentTypeId);
138
139
export const CriteriaTypeIdValues = enumToIds(CriteriaTypeId);
140