forked from Medium/snowflake
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstants.js
More file actions
136 lines (120 loc) · 3.9 KB
/
Copy pathconstants.js
File metadata and controls
136 lines (120 loc) · 3.9 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// @flow
import * as d3 from 'd3'
import importedTracks from './tracks';
export type TrackId = 'MOBILE' | 'WEB_CLIENT' | 'FOUNDATIONS' | 'SERVERS' |
'DELIVERY' | 'COMMUNICATION' | 'CRAFT' | 'INITIATIVE' |
'CAREER_DEVELOPMENT' | 'ORG_DESIGN' | 'WELLBEING' | 'ACCOMPLISHMENT' |
'MENTORSHIP' | 'EVANGELISM' | 'RECRUITING' | 'COMMUNITY'
export type Milestone = 0 | 1 | 2 | 3 | 4 | 5
export type MilestoneMap = {
/*'MOBILE': Milestone,*/
'WEB_CLIENT': Milestone,
'FOUNDATIONS': Milestone,
'SERVERS': Milestone,
'DELIVERY': Milestone,
'COMMUNICATION': Milestone,
'CRAFT': Milestone,
'INITIATIVE': Milestone,
'CAREER_DEVELOPMENT': Milestone,
'ORG_DESIGN': Milestone,
'WELLBEING': Milestone,
'ACCOMPLISHMENT': Milestone,
'MENTORSHIP': Milestone,
'EVANGELISM': Milestone,
'RECRUITING': Milestone,
'COMMUNITY': Milestone
}
export const milestones = [0, 1, 2, 3, 4, 5]
export const milestoneToPoints = (milestone: Milestone): number => {
switch (milestone) {
case 0: return 0
case 1: return 1
case 2: return 3
case 3: return 6
case 4: return 12
case 5: return 20
default: return 0
}
}
export const pointsToLevels = {
'0': '1',
'17': '2',
'36': '3',
'49': '4',
'62': '5',
}
export const maxLevel = 135
export type Track = {
displayName: string,
category: string, // TK categoryId type?
description: string,
milestones: {
summary: string,
signals: string[],
examples: string[]
}[]
}
type Tracks = {|
/*'MOBILE': Track,*/
'WEB_CLIENT': Track,
'FOUNDATIONS': Track,
'SERVERS': Track,
'DELIVERY': Track,
'COMMUNICATION': Track,
'CRAFT': Track,
'INITIATIVE': Track,
'CAREER_DEVELOPMENT': Track,
'ORG_DESIGN': Track,
'WELLBEING': Track,
'ACCOMPLISHMENT': Track,
'MENTORSHIP': Track,
'EVANGELISM': Track,
'RECRUITING': Track,
'COMMUNITY': Track
|}
export const tracks: Tracks = Object.keys(importedTracks)
.filter(key => key !== 'MOBILE')
.reduce((obj, key) => {
obj[key] = importedTracks[key];
return obj;
}, {});
export const trackIds: TrackId[] = Object.keys(tracks)
export const categoryIds: Set<string> = trackIds.reduce((set, trackId) => {
set.add(tracks[trackId].category)
return set
}, new Set())
export const categoryPointsFromMilestoneMap = (milestoneMap: MilestoneMap) => {
let pointsByCategory = new Map()
trackIds.forEach((trackId) => {
const milestone = milestoneMap[trackId]
const categoryId = tracks[trackId].category
let currentPoints = pointsByCategory.get(categoryId) || 0
pointsByCategory.set(categoryId, currentPoints + milestoneToPoints(milestone))
})
return Array.from(categoryIds.values()).map(categoryId => {
const points = pointsByCategory.get(categoryId)
return { categoryId, points: pointsByCategory.get(categoryId) || 0 }
})
}
export const totalPointsFromMilestoneMap = (milestoneMap: MilestoneMap): number =>
trackIds.map(trackId => milestoneToPoints(milestoneMap[trackId]))
.reduce((sum, addend) => (sum + addend), 0)
export const categoryColorScale = d3.scaleOrdinal()
.domain(categoryIds)
.range(['#37B067', '#6296BC', '#EDB40D', '#7FD7C1'])
export const titles = [
{label: 'Engineer I', minPoints: 0, maxPoints: 16},
{label: 'Engineer II', minPoints: 17, maxPoints: 35},
{label: 'Senior Engineer I', minPoints: 36, maxPoints: 48},
{label: 'Manager', minPoints: 36, maxPoints: 57},
{label: 'Senior Engineer II', minPoints: 49, maxPoints: 61},
{label: 'Manager', minPoints: 58, maxPoints: 89},
{label: 'Staff Engineer', minPoints: 62},
{label: 'Director of Engineering', minPoints: 90}
]
export const eligibleTitles = (milestoneMap: MilestoneMap): string[] => {
const totalPoints = totalPointsFromMilestoneMap(milestoneMap)
return titles.filter(title => (title.minPoints === undefined || totalPoints >= title.minPoints)
&& (title.maxPoints === undefined || totalPoints <= title.maxPoints))
.map(title => title.label)
}