diff --git a/crush.json b/crush.json new file mode 100644 index 0000000..5f2ed2f --- /dev/null +++ b/crush.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://charm.land/crush.json", + "lsp": { + "gopls": { + "options": { + "gofumpt": true, + "codelenses": { + "gc_details": true, + "generate": true, + "run_govulncheck": true, + "test": true, + "tidy": true, + "upgrade_dependency": true + }, + "hints": { + "assignVariableTypes": true, + "compositeLiteralFields": true, + "compositeLiteralTypes": true, + "constantValues": true, + "functionTypeParameters": true, + "parameterNames": true, + "rangeVariableTypes": true + }, + "analyses": { + "nilness": true, + "unusedparams": true, + "unusedvariable": true, + "unusedwrite": true, + "useany": true + }, + "staticcheck": true, + "directoryFilters": [ + "-.git", + "-node_modules" + ], + "semanticTokens": true + } + } + } +} diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index 96214d7..0ba48f2 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -179,7 +179,7 @@ func (s *Scheduler) tick(ctx context.Context) { } }() - now := time.Now() + now := time.Now().UTC() configs, err := s.store.GetDueConfigs(ctx, now) if err != nil { s.logger.Error("failed to get due configs", "err", err) @@ -257,8 +257,8 @@ func (s *Scheduler) RunNow(ctx context.Context, configID int64, progress *atomic s.logger.Debug("RunNow: feed metadata updated") s.logger.Debug("RunNow: calculating next run") - now := time.Now() - nextRun, err := gronx.NextTick(cfg.CronExpr, false) + now := time.Now().UTC() + nextRun, err := gronx.NextTick(cfg.CronExpr, true) if err != nil { return stats, fmt.Errorf("calculate next run: %w", err) } @@ -277,7 +277,7 @@ func (s *Scheduler) RunNow(ctx context.Context, configID int64, progress *atomic func (s *Scheduler) collectNewItems(ctx context.Context, results []*FetchResult) ([]email.FeedGroup, int, error) { var feedGroups []email.FeedGroup totalNew := 0 - maxAge := time.Now().Add(-itemMaxAge) + maxAge := time.Now().UTC().Add(-itemMaxAge) feedErrors := 0 for _, result := range results { @@ -486,8 +486,8 @@ func (s *Scheduler) processConfig(ctx context.Context, cfg *store.Config) error } } - now := time.Now() - nextRun, err := gronx.NextTick(cfg.CronExpr, false) + now := time.Now().UTC() + nextRun, err := gronx.NextTick(cfg.CronExpr, true) if err != nil { return fmt.Errorf("calculate next run: %w", err) } diff --git a/ssh/commands.go b/ssh/commands.go index 92691c6..a9debe4 100644 --- a/ssh/commands.go +++ b/ssh/commands.go @@ -288,7 +288,7 @@ func handleLogs(ctx context.Context, sess ssh.Session, user *store.User, st *sto } func formatRelativeTime(t time.Time) string { - now := time.Now() + now := time.Now().UTC() diff := t.Sub(now) if diff < 0 { diff --git a/ssh/scp.go b/ssh/scp.go index d18500c..b02d1b7 100644 --- a/ssh/scp.go +++ b/ssh/scp.go @@ -182,7 +182,7 @@ func (h *scpHandler) Write(s ssh.Session, entry *scp.FileEntry) (int64, error) { } func calculateNextRun(cronExpr string) (time.Time, error) { - return gronx.NextTick(cronExpr, false) + return gronx.NextTick(cronExpr, true) } type configFileInfo struct { diff --git a/store/configs.go b/store/configs.go index 371e576..4e58cd9 100644 --- a/store/configs.go +++ b/store/configs.go @@ -49,7 +49,7 @@ func (db *DB) CreateConfig(ctx context.Context, userID int64, filename, email, c InlineContent: inline, RawText: rawText, NextRun: sql.NullTime{Time: nextRun, Valid: true}, - CreatedAt: time.Now(), + CreatedAt: time.Now().UTC(), }, nil } @@ -78,7 +78,7 @@ func (db *DB) CreateConfigTx(ctx context.Context, tx *sql.Tx, userID int64, file InlineContent: inline, RawText: rawText, NextRun: sql.NullTime{Time: nextRun, Valid: true}, - CreatedAt: time.Now(), + CreatedAt: time.Now().UTC(), }, nil } @@ -219,7 +219,7 @@ func (db *DB) ActivateConfig(ctx context.Context, userID int64, filename string) return err } - nextRun, err := gronx.NextTick(cfg.CronExpr, false) + nextRun, err := gronx.NextTick(cfg.CronExpr, true) if err != nil { return fmt.Errorf("calculate next run: %w", err) } diff --git a/store/users.go b/store/users.go index 90fb1d0..298b65f 100644 --- a/store/users.go +++ b/store/users.go @@ -42,7 +42,7 @@ func (db *DB) GetOrCreateUser(ctx context.Context, pubkeyFP, pubkey string) (*Us ID: id, PubkeyFP: pubkeyFP, Pubkey: pubkey, - CreatedAt: time.Now(), + CreatedAt: time.Now().UTC(), }, nil }