mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	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>
This commit is contained in:
		| @@ -17,6 +17,7 @@ type Config interface { | |||||||
| 	DoRunAtStart() bool | 	DoRunAtStart() bool | ||||||
| 	GetSchedule() string | 	GetSchedule() string | ||||||
| 	FormatMessage(name, status string, doer *models.User, args ...interface{}) string | 	FormatMessage(name, status string, doer *models.User, args ...interface{}) string | ||||||
|  | 	DoNoticeOnSuccess() bool | ||||||
| } | } | ||||||
|  |  | ||||||
| // BaseConfig represents the basic config for a Cron task | // BaseConfig represents the basic config for a Cron task | ||||||
| @@ -24,6 +25,7 @@ type BaseConfig struct { | |||||||
| 	Enabled         bool | 	Enabled         bool | ||||||
| 	RunAtStart      bool | 	RunAtStart      bool | ||||||
| 	Schedule        string | 	Schedule        string | ||||||
|  | 	NoSuccessNotice bool | ||||||
| } | } | ||||||
|  |  | ||||||
| // OlderThanConfig represents a cron task with OlderThan setting | // OlderThanConfig represents a cron task with OlderThan setting | ||||||
| @@ -53,6 +55,11 @@ func (b *BaseConfig) DoRunAtStart() bool { | |||||||
| 	return b.RunAtStart | 	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 | // FormatMessage returns a message for the task | ||||||
| func (b *BaseConfig) FormatMessage(name, status string, doer *models.User, args ...interface{}) string { | func (b *BaseConfig) FormatMessage(name, status string, doer *models.User, args ...interface{}) string { | ||||||
| 	realArgs := make([]interface{}, 0, len(args)+2) | 	realArgs := make([]interface{}, 0, len(args)+2) | ||||||
|   | |||||||
| @@ -98,9 +98,11 @@ func (t *Task) RunWithUser(doer *models.User, config Config) { | |||||||
| 			} | 			} | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
|  | 		if config.DoNoticeOnSuccess() { | ||||||
| 			if err := models.CreateNotice(models.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil { | 			if err := models.CreateNotice(models.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil { | ||||||
| 				log.Error("CreateNotice: %v", err) | 				log.Error("CreateNotice: %v", err) | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ func registerUpdateMirrorTask() { | |||||||
| 		Enabled:         true, | 		Enabled:         true, | ||||||
| 		RunAtStart:      false, | 		RunAtStart:      false, | ||||||
| 		Schedule:        "@every 10m", | 		Schedule:        "@every 10m", | ||||||
|  | 		NoSuccessNotice: true, | ||||||
| 	}, func(ctx context.Context, _ *models.User, _ Config) error { | 	}, func(ctx context.Context, _ *models.User, _ Config) error { | ||||||
| 		return mirror_service.Update(ctx) | 		return mirror_service.Update(ctx) | ||||||
| 	}) | 	}) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zeripath
					zeripath