forked from mudrii/openclaw-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh.go
More file actions
59 lines (45 loc) · 1.91 KB
/
refresh.go
File metadata and controls
59 lines (45 loc) · 1.91 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
package dashboard
import (
"context"
"time"
apprefresh "github.com/mudrii/openclaw-dashboard/internal/apprefresh"
)
type tokenBucket = apprefresh.TokenBucket
type tokenUsageEntry = apprefresh.TokenUsageEntry
type sessionStoreFile = apprefresh.SessionStoreFile
var refreshCollectorFunc = runRefreshCollectorWithContext
func runRefreshCollectorWithContext(ctx context.Context, dashboardDir, openclawPath string, cfgOpt ...Config) error {
return apprefresh.RunRefreshCollector(ctx, dashboardDir, openclawPath, cfgOpt...)
}
func titleCase(s string) string {
return apprefresh.TitleCase(s)
}
func trimLabel(s string) string {
return apprefresh.TrimLabel(s)
}
func modelName(model string) string {
return apprefresh.ModelName(model)
}
func collectCrons(cronPath string, loc *time.Location) []map[string]any {
return apprefresh.CollectCrons(cronPath, loc)
}
func buildDailyChart(now time.Time, dailyCosts map[string]map[string]float64,
dailyTokens map[string]map[string]int, dailyCalls map[string]map[string]int,
dailySubagentCosts map[string]float64, dailySubagentCount map[string]int,
dashboardDir string) []map[string]any {
return apprefresh.BuildDailyChart(now, dailyCosts, dailyTokens, dailyCalls, dailySubagentCosts, dailySubagentCount, dashboardDir)
}
func buildAlerts(totalCostToday, costHigh, costWarn float64,
crons []map[string]any, sessions []map[string]any,
contextThreshold float64, gateway map[string]any, memThresholdKB float64) []map[string]any {
return apprefresh.BuildAlerts(totalCostToday, costHigh, costWarn, crons, sessions, contextThreshold, gateway, memThresholdKB)
}
func buildCostBreakdown(m map[string]*tokenBucket) []map[string]any {
return apprefresh.BuildCostBreakdown(m)
}
func filterByDate(runs []map[string]any, targetDate, op string) []map[string]any {
return apprefresh.FilterByDate(runs, targetDate, op)
}
func limitSlice[T any](s []T, max int) []T {
return apprefresh.LimitSlice(s, max)
}