From 41d36ac84a370b95c24c43466378c4b86bc3dafb Mon Sep 17 00:00:00 2001 From: biast12 Date: Wed, 4 Mar 2026 23:57:52 +0100 Subject: [PATCH 1/4] gdl --- go.mod | 2 ++ internal/daemon/daemon.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dd12ff3..0f62ba4 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/TicketsBot-cloud/discord-entitlements-db-sync go 1.22.0 +replace github.com/TicketsBot-cloud/gdl => ../gdl + require ( github.com/TicketsBot-cloud/common v0.0.0-20251026182733-99fa0dc31d90 github.com/TicketsBot-cloud/database v0.0.0-20251230153828-3a49abf50812 diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 61bb92a..9486512 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -204,7 +204,7 @@ func (d *Daemon) nextPage(ctx context.Context, afterId uint64, entitlements []en fetched, err := rest.ListEntitlements(ctx, d.config.Discord.Token, nil, d.config.Discord.ApplicationId, rest.EntitlementQueryOptions{ After: utils.Ptr(afterId), Limit: utils.Ptr(pageLimit), - ExcludedEnded: utils.Ptr(true), + ExcludeEnded: utils.Ptr(true), }) if err != nil { return nil, err From 5c466836b4b18ba6ad799f46af6b6f95ad3a7bb9 Mon Sep 17 00:00:00 2001 From: biast12 Date: Mon, 27 Apr 2026 20:51:06 +0200 Subject: [PATCH 2/4] Use time.Since for duration calculation Replace time.Now().Sub(start) with time.Since(start) in the deferred duration calculation. This is more idiomatic and concise while preserving the same behavior when checking against the execution timeout; improves readability. --- internal/daemon/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 9486512..6494e6a 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -66,7 +66,7 @@ func (d *Daemon) RunOnce(ctx context.Context) error { start := time.Now() defer func() { - duration := time.Now().Sub(start) + duration := time.Since(start) if duration > (d.config.ExecutionTimeout / 2.0) { d.logger.Warn("Execution took more than 50% of the timeout", zap.Duration("duration", duration)) } From 587ca245f18f8d04423275d2a3ba256645c06410 Mon Sep 17 00:00:00 2001 From: biast12 Date: Mon, 27 Apr 2026 20:51:14 +0200 Subject: [PATCH 3/4] Add .env.example environment template Introduce a new .env.example file providing a template of required environment variables for the application. Variables include daemon and scheduling settings (DAEMON, RUN_FREQUENCY, EXECUTION_TIMEOUT), observability and logging (SENTRY_DSN, JSON_LOGS, LOG_LEVEL), Discord integration (DISCORD_APPLICATION_ID, DISCORD_TOKEN, DISCORD_PROXY_HOST), DATABASE_URI, and MAX_REMOVALS_THRESHOLD to document configuration expectations for developers. --- .env.example | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d965c42 --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +DAEMON= +RUN_FREQUENCY= +EXECUTION_TIMEOUT= +SENTRY_DSN= +JSON_LOGS= +LOG_LEVEL= +DISCORD_APPLICATION_ID= +DISCORD_TOKEN= +DISCORD_PROXY_HOST= +DATABASE_URI= +MAX_REMOVALS_THRESHOLD= \ No newline at end of file From f3c9040919b4c6449808af67648091c0d27c2d24 Mon Sep 17 00:00:00 2001 From: biast12 Date: Mon, 27 Apr 2026 20:51:32 +0200 Subject: [PATCH 4/4] Align fields in ListEntitlements call Adjust spacing/alignment of the struct literal fields in the rest.ListEntitlements call in internal/daemon/daemon.go to match project formatting (gofmt). This is a non-functional whitespace-only change. --- internal/daemon/daemon.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 6494e6a..0a43a9a 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -202,9 +202,9 @@ func (d *Daemon) nextPage(ctx context.Context, afterId uint64, entitlements []en d.logger.Debug("Fetching page of entitlements", zap.Uint64("after", afterId), zap.Int("limit", pageLimit), zap.Int("total", len(entitlements))) fetched, err := rest.ListEntitlements(ctx, d.config.Discord.Token, nil, d.config.Discord.ApplicationId, rest.EntitlementQueryOptions{ - After: utils.Ptr(afterId), - Limit: utils.Ptr(pageLimit), - ExcludeEnded: utils.Ptr(true), + After: utils.Ptr(afterId), + Limit: utils.Ptr(pageLimit), + ExcludeEnded: utils.Ptr(true), }) if err != nil { return nil, err