feat(demo): reset the demo instance every 20 minutes with a countdown
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m34s

DEMO_RESET_MINUTES (default 20, 0 = off) resets the database to the
sample data. Demo accounts get fixed IDs so sessions survive; requests
hold a read lock so the reset never runs under a half-finished request
(streams excluded). DEMO_RESET goes to every connection, /auth/status
announces the next reset. The app shows "✨ Demo · Reset in MM:SS" in
place of the version, then clears cached answers, remounts the views,
reloads in the background and shows a short notice; if no event
arrives (long polling) it asks the server after the countdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-29 14:22:06 +01:00
1 parent afd3b0347c
commit 6b9eb62caf
12 files changed
+348 -9

No files matched your search

+12
View File
@@ -2,6 +2,7 @@ package config
import (
"crypto/rand"
"strconv"
"encoding/hex"
"log/slog"
"os"
@@ -22,6 +23,8 @@ type Config struct {
LogLevel string
Debug bool
DemoMode bool
// DemoResetMinutes: in demo mode the database is reset to the sample data this often (0 = never)
DemoResetMinutes int
// Optional SMTP environment variables (can also be overridden/configured in DB system_settings)
SMTPHost string
@@ -161,6 +164,7 @@ func Load() *Config {
LogLevel: logLevel,
Debug: debug,
DemoMode: demoMode,
DemoResetMinutes: demoResetMinutes(),
SMTPHost: smtpHost,
SMTPPort: smtpPort,
SMTPUser: smtpUser,
@@ -197,3 +201,11 @@ func getEnv(key, fallback string) string {
}
return fallback
}
func demoResetMinutes() int {
n, err := strconv.Atoi(strings.TrimSpace(getEnv("DEMO_RESET_MINUTES", "20")))
if err != nil || n < 0 {
return 20
}
return n
}