0.2.45 - Advanced analytics, logout old versions
This commit is contained in:
@@ -75,7 +75,8 @@ type Config struct {
|
||||
SyncUserID string
|
||||
SyncAPIKey string
|
||||
|
||||
// AnalyticsRetention is how long raw row events are kept before being pruned.
|
||||
// AnalyticsRetention is how long raw row and journey events are kept before pruning.
|
||||
// Load enforces a 30-day floor so the per-user history promise cannot be configured away.
|
||||
AnalyticsRetention time.Duration
|
||||
|
||||
// Sonarr is optional. When configured, its local calendar supplies the informational
|
||||
@@ -192,6 +193,9 @@ func Load() (Config, error) {
|
||||
ForYouRefreshInterval: duration("MEMBY_FOR_YOU_REFRESH_INTERVAL", 24*time.Hour),
|
||||
ForYouRebuildHour: integer("MEMBY_FOR_YOU_REBUILD_HOUR", 4),
|
||||
}
|
||||
if c.AnalyticsRetention < 30*24*time.Hour {
|
||||
c.AnalyticsRetention = 30 * 24 * time.Hour
|
||||
}
|
||||
|
||||
if c.EmbyURL == "" {
|
||||
return c, fmt.Errorf("MEMBY_EMBY_URL is required")
|
||||
|
||||
@@ -63,3 +63,17 @@ func TestRecommendationWeightsMustBeJSON(t *testing.T) {
|
||||
t.Fatal("expected invalid recommendation weights to fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnalyticsRetentionCannotDropBelowThirtyDays(t *testing.T) {
|
||||
t.Setenv("MEMBY_EMBY_URL", "http://emby")
|
||||
t.Setenv("MEMBY_DATABASE_URL", "postgres://memby")
|
||||
t.Setenv("MEMBY_ANALYTICS_RETENTION", "168h")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.AnalyticsRetention != 30*24*time.Hour {
|
||||
t.Fatalf("analytics retention = %v, want 30 days", cfg.AnalyticsRetention)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user