-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstevebeattie_test.go
More file actions
146 lines (136 loc) · 3.25 KB
/
stevebeattie_test.go
File metadata and controls
146 lines (136 loc) · 3.25 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
137
138
139
140
141
142
143
144
145
146
package ditzy
import (
"testing"
)
func TestSteveBeattiePacificTimezone(t *testing.T) {
// stevebeattie's actual activity data from the system
// He lives in Portland, OR (UTC-7 in summer, UTC-8 in winter)
hourCounts := map[int]int{
0: 11, // 5pm PST / 4pm PDT
1: 5, // 6pm PST / 5pm PDT
2: 12, // 7pm PST / 6pm PDT
3: 5, // 8pm PST / 7pm PDT
4: 11, // 9pm PST / 8pm PDT
5: 8, // 10pm PST / 9pm PDT
6: 11, // 11pm PST / 10pm PDT
7: 7, // midnight PST / 11pm PDT
8: 6, // 1am PST / midnight PDT
9: 3, // 2am PST / 1am PDT
10: 2, // 3am PST / 2am PDT
11: 0, // 4am PST / 3am PDT
12: 0, // 5am PST / 4am PDT
13: 0, // 6am PST / 5am PDT
14: 0, // 7am PST / 6am PDT
15: 9, // 8am PST / 7am PDT
16: 8, // 9am PST / 8am PDT
17: 23, // 10am PST / 9am PDT
18: 23, // 11am PST / 10am PDT
19: 13, // noon PST / 11am PDT
20: 10, // 1pm PST / noon PDT (lunch dip)
21: 11, // 2pm PST / 1pm PDT
22: 13, // 3pm PST / 2pm PDT
23: 16, // 4pm PST / 3pm PDT
}
// Half-hour counts for lunch detection
halfHourCounts := map[float64]int{
0.0: 6,
0.5: 5,
1.0: 3,
1.5: 2,
2.0: 7,
2.5: 5,
3.0: 3,
3.5: 2,
4.0: 6,
4.5: 5,
5.0: 4,
5.5: 4,
6.0: 6,
6.5: 5,
7.0: 4,
7.5: 3,
8.0: 3,
8.5: 3,
9.0: 2,
9.5: 1,
10.0: 1,
10.5: 1,
11.0: 0,
11.5: 0,
12.0: 0,
12.5: 0,
13.0: 0,
13.5: 0,
14.0: 0,
14.5: 0,
15.0: 5,
15.5: 4,
16.0: 4,
16.5: 4,
17.0: 12,
17.5: 11,
18.0: 12,
18.5: 11,
19.0: 7,
19.5: 6,
20.0: 5, // Lunch dip at noon PDT
20.5: 5,
21.0: 6,
21.5: 5,
22.0: 7,
22.5: 6,
23.0: 8,
23.5: 8,
}
totalActivity := 207
quietHours := []int{10, 11, 12, 13, 14} // UTC quiet hours
midQuiet := 12.5
activeStart := 15.0 // First significant activity at 15 UTC
bestGlobalLunch := globalLunchPattern{
startUTC: 20.5,
endUTC: 21.0,
confidence: 0.8,
dropPercent: 50.0,
}
// Evaluate candidates
candidates := evaluate(evaluationInput{
username: "stevebeattie",
hourCounts: hourCounts,
halfHourCounts: halfHourCounts,
totalActivity: totalActivity,
quietHours: quietHours,
midQuiet: midQuiet,
activeStart: activeStart,
bestGlobalLunch: bestGlobalLunch,
profileTimezone: "",
})
// Check that we have multiple candidates
if len(candidates) < 3 {
t.Errorf("Expected at least 3 candidates, got %d", len(candidates))
}
// Check that UTC-7 or UTC-8 is in the top 3
foundPacific := false
for i := 0; i < len(candidates) && i < 3; i++ {
offset := candidates[i].offset
if offset == -7 || offset == -8 {
foundPacific = true
t.Logf("Found Pacific timezone at position %d: UTC%+.0f with confidence %.1f%%",
i+1, offset, candidates[i].confidence)
break
}
}
if !foundPacific {
t.Errorf("UTC-7 or UTC-8 should be in top 3 candidates for stevebeattie (Portland, OR)")
t.Logf("Top 3 candidates:")
for i := 0; i < len(candidates) && i < 3; i++ {
t.Logf(" %d. UTC%+.0f (%.1f%% confidence)",
i+1, candidates[i].offset, candidates[i].confidence)
}
}
// Additionally check that UTC-7 has reasonable confidence (>5%)
for _, c := range candidates {
if c.offset == -7 && c.confidence < 5 {
t.Errorf("UTC-7 confidence too low: %.1f%% (expected >5%%)", c.confidence)
}
}
}