Refactor scheduler and settings UI

This commit is contained in:
Mikhail Chusavitin
2026-03-07 21:10:20 +03:00
parent 27e33db446
commit b2b2f4774c
23 changed files with 1601 additions and 551 deletions

View File

@@ -17,6 +17,7 @@ type Config struct {
Pricing PricingConfig `yaml:"pricing"`
Export ExportConfig `yaml:"export"`
Alerts AlertsConfig `yaml:"alerts"`
Scheduler SchedulerConfig `yaml:"scheduler"`
Notifications NotificationsConfig `yaml:"notifications"`
Logging LoggingConfig `yaml:"logging"`
}
@@ -78,6 +79,16 @@ type AlertsConfig struct {
TrendingThresholdPercent int `yaml:"trending_threshold_percent"`
}
type SchedulerConfig struct {
Enabled bool `yaml:"enabled"`
PollInterval time.Duration `yaml:"poll_interval"`
AlertsInterval time.Duration `yaml:"alerts_interval"`
UpdatePricesInterval time.Duration `yaml:"update_prices_interval"`
UpdatePopularityInterval time.Duration `yaml:"update_popularity_interval"`
ResetWeeklyCountersInterval time.Duration `yaml:"reset_weekly_counters_interval"`
ResetMonthlyCountersInterval time.Duration `yaml:"reset_monthly_counters_interval"`
}
type NotificationsConfig struct {
EmailEnabled bool `yaml:"email_enabled"`
SMTPHost string `yaml:"smtp_host"`
@@ -168,6 +179,27 @@ func (c *Config) setDefaults() {
if c.Logging.Output == "" {
c.Logging.Output = "stdout"
}
if c.Scheduler.PollInterval == 0 {
c.Scheduler.PollInterval = 1 * time.Minute
}
if c.Alerts.CheckInterval == 0 {
c.Alerts.CheckInterval = 1 * time.Hour
}
if c.Scheduler.AlertsInterval == 0 {
c.Scheduler.AlertsInterval = c.Alerts.CheckInterval
}
if c.Scheduler.UpdatePricesInterval == 0 {
c.Scheduler.UpdatePricesInterval = 24 * time.Hour
}
if c.Scheduler.UpdatePopularityInterval == 0 {
c.Scheduler.UpdatePopularityInterval = 24 * time.Hour
}
if c.Scheduler.ResetWeeklyCountersInterval == 0 {
c.Scheduler.ResetWeeklyCountersInterval = 7 * 24 * time.Hour
}
if c.Scheduler.ResetMonthlyCountersInterval == 0 {
c.Scheduler.ResetMonthlyCountersInterval = 30 * 24 * time.Hour
}
}
func (c *Config) Address() string {