-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory.go
More file actions
57 lines (42 loc) · 1021 Bytes
/
Copy pathcategory.go
File metadata and controls
57 lines (42 loc) · 1021 Bytes
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
package tracker
import (
_ "embed"
"strings"
)
//go:embed categories.csv
var asset string
type Category struct {
Name string
Score int
}
var categories map[string]Category
func registerCategory(name string, score int) Category {
category := Category{
Name: name,
Score: score,
}
categories[name] = category
return category
}
var activities map[string]Activity
func init() {
categories = make(map[string]Category, 6)
registerCategory("Development", 1)
registerCategory("General", 1)
registerCategory("Writing", 1)
registerCategory("Communication", 0)
registerCategory("Uncategorised", 0)
registerCategory("Entertainment", -1)
registerCategory("Social", -1)
lines := strings.Split(asset, "\n")
activities = make(map[string]Activity, len(lines)-1)
for _, line := range lines {
cols := strings.Split(line, ",")
if len(cols[0]) == 0 {
continue
}
frontApp := cols[0]
category := categories[cols[1]]
activities[frontApp] = Activity{Name: frontApp, Category: category}
}
}