aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-08-05 21:40:36 +0100
committerGitHub <noreply@github.com>2020-08-05 21:40:36 +0100
commit48598a7e835cf9da87ef4d928fbd23fb0c5f5ea6 (patch)
tree736768ff984d6970621e6abdfe57edcd19695927
parent42a31c797b2e8ec38466e41e2e069d1352391348 (diff)
downloadgitea-48598a7e835cf9da87ef4d928fbd23fb0c5f5ea6.tar.gz
gitea-48598a7e835cf9da87ef4d928fbd23fb0c5f5ea6.zip
Mirror System Notice reports are too frequent (#12438)
This PR switches off the success reports from the Update Mirrors cron job as they are too frequent and not necessarily helpful. Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r--modules/cron/setting.go13
-rw-r--r--modules/cron/tasks.go6
-rw-r--r--modules/cron/tasks_basic.go7
3 files changed, 18 insertions, 8 deletions
diff --git a/modules/cron/setting.go b/modules/cron/setting.go
index dd93d03986..5fe9ca6e14 100644
--- a/modules/cron/setting.go
+++ b/modules/cron/setting.go
@@ -17,13 +17,15 @@ type Config interface {
DoRunAtStart() bool
GetSchedule() string
FormatMessage(name, status string, doer *models.User, args ...interface{}) string
+ DoNoticeOnSuccess() bool
}
// BaseConfig represents the basic config for a Cron task
type BaseConfig struct {
- Enabled bool
- RunAtStart bool
- Schedule string
+ Enabled bool
+ RunAtStart bool
+ Schedule string
+ NoSuccessNotice bool
}
// OlderThanConfig represents a cron task with OlderThan setting
@@ -53,6 +55,11 @@ func (b *BaseConfig) DoRunAtStart() bool {
return b.RunAtStart
}
+// DoNoticeOnSuccess returns whether a success notice should be posted
+func (b *BaseConfig) DoNoticeOnSuccess() bool {
+ return !b.NoSuccessNotice
+}
+
// FormatMessage returns a message for the task
func (b *BaseConfig) FormatMessage(name, status string, doer *models.User, args ...interface{}) string {
realArgs := make([]interface{}, 0, len(args)+2)
diff --git a/modules/cron/tasks.go b/modules/cron/tasks.go
index a97326bd0f..6f3a96fd3f 100644
--- a/modules/cron/tasks.go
+++ b/modules/cron/tasks.go
@@ -98,8 +98,10 @@ func (t *Task) RunWithUser(doer *models.User, config Config) {
}
return
}
- if err := models.CreateNotice(models.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil {
- log.Error("CreateNotice: %v", err)
+ if config.DoNoticeOnSuccess() {
+ if err := models.CreateNotice(models.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil {
+ log.Error("CreateNotice: %v", err)
+ }
}
})
}
diff --git a/modules/cron/tasks_basic.go b/modules/cron/tasks_basic.go
index 438c4a5004..4da21fc7d9 100644
--- a/modules/cron/tasks_basic.go
+++ b/modules/cron/tasks_basic.go
@@ -16,9 +16,10 @@ import (
func registerUpdateMirrorTask() {
RegisterTaskFatal("update_mirrors", &BaseConfig{
- Enabled: true,
- RunAtStart: false,
- Schedule: "@every 10m",
+ Enabled: true,
+ RunAtStart: false,
+ Schedule: "@every 10m",
+ NoSuccessNotice: true,
}, func(ctx context.Context, _ *models.User, _ Config) error {
return mirror_service.Update(ctx)
})