mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-02-11 16:29:00 -06:00
Cosmetic improvements
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user