Cosmetic improvements

This commit is contained in:
Taras Kushnir
2025-08-17 21:41:37 +03:00
parent 4da1357ed2
commit b74eacd23a
2 changed files with 7 additions and 1 deletions

View File

@@ -338,7 +338,7 @@ func run(ctx context.Context, cfg common.ConfigStore, stderr io.Writer, listener
Store: businessDB,
})
jobs.AddLocked(1*time.Hour, &maintenance.UserEmailNotificationsJob{
RunInterval: 1 * time.Hour,
RunInterval: 3 * time.Hour, // overlap few locked intervals to cover for possible unprocessed notifications
Store: businessDB,
Templates: email.Templates(),
Sender: sender,

View File

@@ -193,7 +193,13 @@ func (j *UserEmailNotificationsJob) retrievePendingNotifications(ctx context.Con
return filtered, nil
}
// NOTE: we should NOT refactor this into "while we have pending notifications {}" loop because some notifications
// are unprocessable by design (e.g. "subscribed-only" notifications for users who don't have subscriptions), therefore
// there are cases when there will always be "pending" notifications.
// If we are not managing to process all of them, we need to modify ChunkSize and Interval (or Lock Inteval) instead
func (j *UserEmailNotificationsJob) RunOnce(ctx context.Context) error {
// TODO: Monitor pending notifications count in Postgres
// so we will know if we have enough processing capacity
notifications, err := j.retrievePendingNotifications(ctx)
if err != nil {
slog.ErrorContext(ctx, "Failed to retrieve pending user notifications", common.ErrAttr(err))