-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_stats.go
More file actions
41 lines (31 loc) · 974 Bytes
/
app_stats.go
File metadata and controls
41 lines (31 loc) · 974 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
package main
import (
"fmt"
"ghostdraft/internal/lcu"
)
// ForceStatsUpdate clears the cache and refreshes stats data from Turso
func (a *App) ForceStatsUpdate() string {
if a.statsProvider == nil {
return "Stats provider not initialized"
}
// Clear the query cache
a.statsProvider.ClearCache()
// Refetch patch info
if err := a.statsProvider.FetchPatch(); err != nil {
return fmt.Sprintf("Failed to refresh: %v", err)
}
return fmt.Sprintf("Cache cleared, using patch %s", a.statsProvider.GetPatch())
}
// GetPersonalStats returns aggregated personal stats from recent match history
func (a *App) GetPersonalStats() *lcu.PersonalStats {
emptyStats := &lcu.PersonalStats{HasData: false}
if !a.lcuClient.IsConnected() {
return emptyStats
}
history, err := a.lcuClient.FetchMatchHistory(20)
if err != nil {
fmt.Printf("Failed to fetch match history: %v\n", err)
return emptyStats
}
return lcu.CalculatePersonalStats(history, a.champions)
}