๐Ÿ“ฆ navidrome / insights

๐Ÿ“„ consts.go ยท 70 lines
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
70package consts

import "time"

// Server configuration
const (
	DefaultPort       = "8080"
	ReadHeaderTimeout = 3 * time.Second
	RateLimitRequests = 1
	RateLimitWindow   = 30 * time.Minute
)

// Cron schedules
const (
	CronSummarize     = "0 */2 * * *" // Every 2 hours
	CronGenerateChart = "5 0 * * *"   // Daily at 00:05 UTC
	CronCleanup       = "30 0 * * *"  // Daily at 00:30 UTC
)

// Data retention and summarization
const (
	SummarizeLookbackDays = 5
	PurgeRetentionDays    = 33
)

// File paths and directories
const (
	ChartDataDir   = "web/chartdata"
	WebIndexPath   = "web/index.html"
	ChartsJSONFile = "charts.json"
	SummariesDir   = "summaries"
)

// File permissions
const (
	DirPermissions  = 0750
	FilePermissions = 0600
)

// Date formats
const (
	DateFormat      = "2006-01-02"
	DateTimeFormat  = "2006-01-02 15:04:05"
	ChartDateFormat = "Jan 02, 2006"
)

// Chart configuration
const (
	ChartWidth           = "1400px"
	ChartHeight          = "500px"
	TopVersionsCount     = 15
	VersionSelectionDays = 60    // Rolling window (in days) for top-N version selection
	IncompleteThreshold  = 0.8   // 20% drop indicates incomplete data
	PlayerGroupThreshold = 0.002 // 0.2% threshold for grouping players
)

// Chart colors and styling
const (
	ChartBackgroundColor = "#ffffff"
	ChartTextColor       = "#000000"
	GapHighlightColor    = "rgba(200, 200, 200, 0.3)"
	GapLabelColor        = "#888888"
)

// API configuration
const (
	AuthHeaderPrefix = "Bearer "
	APIKeyQueryParam = "api_key"
)