Skip to content

Commit d857f1c

Browse files
committed
code cleanup
1 parent efc1e16 commit d857f1c

9 files changed

Lines changed: 125 additions & 186 deletions

File tree

cmd/review-goose/icons_badge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func getIcon(iconType IconType, counts PRCounts) []byte {
5555
}
5656

5757
// Check cache
58-
if cached, ok := cache.Get(incoming, outgoing); ok {
58+
if cached, ok := cache.Lookup(incoming, outgoing); ok {
5959
return cached
6060
}
6161

cmd/review-goose/main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ func (app *App) updatePRs(ctx context.Context) {
764764

765765
// Process notifications using the simplified state manager
766766
slog.Debug("[DEBUG] Processing PR state updates and notifications")
767-
app.updatePRStatesAndNotify(ctx)
767+
app.processNotifications(ctx)
768768
slog.Debug("[DEBUG] Completed PR state updates and notifications")
769769
}
770770

@@ -927,7 +927,7 @@ func (app *App) updatePRsWithWait(ctx context.Context) {
927927

928928
// Process notifications using the simplified state manager
929929
slog.Info("[FLOW] About to process PR state updates and notifications")
930-
app.updatePRStatesAndNotify(ctx)
930+
app.processNotifications(ctx)
931931
slog.Info("[FLOW] Completed PR state updates and notifications")
932932
// Mark initial load as complete after first successful update
933933
if !app.initialLoadComplete {
@@ -998,9 +998,7 @@ func (app *App) tryAutoOpenPR(ctx context.Context, pr *PR, autoBrowserEnabled bo
998998
}
999999
}
10001000

1001-
// checkForNewlyBlockedPRs provides backward compatibility for tests
1002-
// while using the new state manager internally.
1001+
// checkForNewlyBlockedPRs provides backward compatibility for tests.
10031002
func (app *App) checkForNewlyBlockedPRs(ctx context.Context) {
1004-
// Simply delegate to the new implementation
1005-
app.updatePRStatesAndNotify(ctx)
1003+
app.processNotifications(ctx)
10061004
}

cmd/review-goose/notifications.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,3 @@ func (app *App) sendPRNotification(ctx context.Context, pr *PR, title string, so
116116
*playedSound = true
117117
}
118118
}
119-
120-
// updatePRStatesAndNotify is the simplified replacement for checkForNewlyBlockedPRs.
121-
func (app *App) updatePRStatesAndNotify(ctx context.Context) {
122-
// Simple and clear: just process notifications
123-
app.processNotifications(ctx)
124-
}

cmd/review-goose/ratelimit.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

cmd/review-goose/reliability.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (hm *healthMonitor) recordCacheAccess(hit bool) {
144144
}
145145
}
146146

147-
func (hm *healthMonitor) getMetrics() map[string]any {
147+
func (hm *healthMonitor) metrics() map[string]any {
148148
hm.mu.RLock()
149149
defer hm.mu.RUnlock()
150150

@@ -172,7 +172,7 @@ func (hm *healthMonitor) getMetrics() map[string]any {
172172
}
173173

174174
func (hm *healthMonitor) logMetrics() {
175-
metrics := hm.getMetrics()
175+
m := hm.metrics()
176176

177177
// Get sprinkler connection status
178178
sprinklerConnected := false
@@ -186,11 +186,11 @@ func (hm *healthMonitor) logMetrics() {
186186
}
187187

188188
slog.Info("[HEALTH] Application metrics",
189-
"uptime", metrics["uptime"],
190-
"api_calls", metrics["api_calls"],
191-
"api_errors", metrics["api_errors"],
192-
"error_rate_pct", fmt.Sprintf("%.1f", metrics["error_rate"]),
193-
"cache_hit_rate_pct", fmt.Sprintf("%.1f", metrics["cache_hit_rate"]),
189+
"uptime", m["uptime"],
190+
"api_calls", m["api_calls"],
191+
"api_errors", m["api_errors"],
192+
"error_rate_pct", fmt.Sprintf("%.1f", m["error_rate"]),
193+
"cache_hit_rate_pct", fmt.Sprintf("%.1f", m["cache_hit_rate"]),
194194
"sprinkler_connected", sprinklerConnected,
195195
"sprinkler_last_connected", sprinklerLastConnected)
196196
}

cmd/review-goose/sprinkler.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,14 @@ func (sm *sprinklerMonitor) processEvents(ctx context.Context) {
282282
func (sm *sprinklerMonitor) checkAndNotify(ctx context.Context, evt prEvent) {
283283
start := time.Now()
284284

285-
user := sm.currentUser()
285+
// Determine user: targetUser takes precedence over currentUser
286+
user := ""
287+
if sm.app.currentUser != nil {
288+
user = sm.app.currentUser.GetLogin()
289+
}
290+
if sm.app.targetUser != "" {
291+
user = sm.app.targetUser
292+
}
286293
if user == "" {
287294
slog.Debug("[SPRINKLER] Skipping check - no user configured", "url", evt.url)
288295
return
@@ -327,18 +334,6 @@ func (sm *sprinklerMonitor) checkAndNotify(ctx context.Context, evt prEvent) {
327334
sm.sendNotifications(ctx, evt.url, repo, n, act)
328335
}
329336

330-
// currentUser returns the configured user for the sprinkler monitor.
331-
func (sm *sprinklerMonitor) currentUser() string {
332-
user := ""
333-
if sm.app.currentUser != nil {
334-
user = sm.app.currentUser.GetLogin()
335-
}
336-
if sm.app.targetUser != "" {
337-
user = sm.app.targetUser
338-
}
339-
return user
340-
}
341-
342337
// fetchTurnData retrieves PR data from Turn API with retry logic.
343338
func (sm *sprinklerMonitor) fetchTurnData(ctx context.Context, evt prEvent, repo string, n int, start time.Time) (*turn.CheckResponse, bool) {
344339
var data *turn.CheckResponse

0 commit comments

Comments
 (0)