Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaff96c5

Browse files
minor refactoring
1 parent4bfccab commitaff96c5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎enterprise/coderd/prebuilds/reconcile.go‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
3948
typeStoreReconcilerstruct {
4049
store database.Store
4150
cfg codersdk.PrebuildsConfig
@@ -470,11 +479,6 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
470479
returnmultiErr.ErrorOrNil()
471480
}
472481

473-
const (
474-
NotificationTypeAdmin="admin"
475-
NotificationTypeAuthor="author"
476-
)
477-
478482
func (c*StoreReconciler)notifyPrebuildFailureLimitReached(ctx context.Context,ps prebuilds.PresetSnapshot)error {
479483
// nolint:gocritic // Necessary to query all the required data.
480484
ctx=dbauthz.AsSystemRestricted(ctx)
@@ -508,7 +512,7 @@ func (c *StoreReconciler) notifyTemplateAdmins(ctx context.Context, ps prebuilds
508512
})
509513
iferr==nil {
510514
// Cooldown exists, check if 7 days have passed
511-
ifc.clock.Since(cooldown.LastNotificationSent)<7*24*time.Hour {
515+
ifc.clock.Since(cooldown.LastNotificationSent)<AdminNotificationCooldown {
512516
returnnil// Still in cooldown
513517
}
514518
}
@@ -554,7 +558,7 @@ func (c *StoreReconciler) notifyTemplateAuthor(ctx context.Context, ps prebuilds
554558
})
555559
iferr==nil {
556560
// Cooldown exists, check if 1 day has passed
557-
ifc.clock.Since(cooldown.LastNotificationSent)<24*time.Hour {
561+
ifc.clock.Since(cooldown.LastNotificationSent)<AuthorNotificationCooldown {
558562
returnnil// Still in cooldown
559563
}
560564
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp