@@ -36,6 +36,15 @@ import (
3636"golang.org/x/xerrors"
3737)
3838
39+ const (
40+ NotificationTypeAdmin = "admin"
41+ NotificationTypeAuthor = "author"
42+
43+ // Notification cooldown periods
44+ AdminNotificationCooldown = 7 * 24 * time .Hour // 7 days
45+ AuthorNotificationCooldown = 24 * time .Hour // 1 day
46+ )
47+
3948type StoreReconciler struct {
4049store database.Store
4150cfg codersdk.PrebuildsConfig
@@ -470,11 +479,6 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
470479return multiErr .ErrorOrNil ()
471480}
472481
473- const (
474- NotificationTypeAdmin = "admin"
475- NotificationTypeAuthor = "author"
476- )
477-
478482func (c * StoreReconciler )notifyPrebuildFailureLimitReached (ctx context.Context ,ps prebuilds.PresetSnapshot )error {
479483// nolint:gocritic // Necessary to query all the required data.
480484ctx = dbauthz .AsSystemRestricted (ctx )
@@ -508,7 +512,7 @@ func (c *StoreReconciler) notifyTemplateAdmins(ctx context.Context, ps prebuilds
508512})
509513if err == nil {
510514// Cooldown exists, check if 7 days have passed
511- if c .clock .Since (cooldown .LastNotificationSent )< 7 * 24 * time . Hour {
515+ if c .clock .Since (cooldown .LastNotificationSent )< AdminNotificationCooldown {
512516return nil // Still in cooldown
513517}
514518}
@@ -554,7 +558,7 @@ func (c *StoreReconciler) notifyTemplateAuthor(ctx context.Context, ps prebuilds
554558})
555559if err == nil {
556560// Cooldown exists, check if 1 day has passed
557- if c .clock .Since (cooldown .LastNotificationSent )< 24 * time . Hour {
561+ if c .clock .Since (cooldown .LastNotificationSent )< AuthorNotificationCooldown {
558562return nil // Still in cooldown
559563}
560564}