This repository was archived by the owner on Jan 22, 2025. It is now read-only.
forked from Medium/snowflake
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconstants.js
112 lines (96 loc) · 3.26 KB
/
constants.js
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
// @flow
import * as d3 from 'd3'
export type TrackId = 'MOBILE' | 'WEB_CLIENT' | 'FOUNDATIONS' | 'SERVERS' |
'PROJECT_MANAGEMENT' | '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 = {
[TrackId]: 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.1',
'5': '1.2',
'11': '1.3',
'17': '2.1',
'23': '2.2',
'29': '2.3',
'36': '3.1',
'43': '3.2',
'50': '3.3',
'58': '4.1',
'66': '4.2',
'74': '4.3',
'90': '5.1',
'110': '5.2',
'135': '5.3',
}
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 = {
[TrackId]: Track,
}
export const tracks: Tracks = compiledTracks;
export const trackIds: TrackId[] = ((Object.keys(tracks): any): TrackId[]).sort((a, b) => {
return tracks[a].category > tracks[b].category ? 1 : -1
})
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(['#00abc2', '#428af6', '#e1439f', '#e54552'])
export const titles = [
{label: 'Engineer I', minPoints: 0, maxPoints: 16},
{label: 'Engineer II', minPoints: 17, maxPoints: 35},
{label: 'Senior Engineer', minPoints: 36, maxPoints: 57},
{label: 'Group Lead', minPoints: 36, maxPoints: 57},
{label: 'Staff Engineer', minPoints: 58, maxPoints: 89},
{label: 'Senior Group Lead', minPoints: 58, maxPoints: 89},
{label: 'Principal Engineer', minPoints: 90},
{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)
}