From 177cbb12fcc46f9f63b4f65b482847eaad6e5f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Fri, 16 Oct 2020 16:21:13 +0200 Subject: [PATCH] chore: make aggregation time configurable (resolve #60) --- config.default.yml | 1 + config/config.go | 1 + services/aggregation.go | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.default.yml b/config.default.yml index 2b4d2e5..ea0a826 100644 --- a/config.default.yml +++ b/config.default.yml @@ -7,6 +7,7 @@ server: app: cleanup: false # only edit, if you know what you're doing + aggregation_time: '02:15' # time at which to run daily aggregation batch jobs custom_languages: vue: Vue jsx: JSX diff --git a/config/config.go b/config/config.go index 44edf4f..b253db9 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,7 @@ var ( type appConfig struct { CleanUp bool `default:"false" env:"WAKAPI_CLEANUP"` + AggregationTime string `yaml:"aggregation_time" default:"02:15" env:"WAKAPI_AGGREGATION_TIME"` CustomLanguages map[string]string `yaml:"custom_languages"` LanguageColors map[string]string `yaml:"-"` } diff --git a/services/aggregation.go b/services/aggregation.go index abea60d..74c1512 100644 --- a/services/aggregation.go +++ b/services/aggregation.go @@ -40,7 +40,6 @@ type AggregationJob struct { } // Schedule a job to (re-)generate summaries every day shortly after midnight -// TODO: Make configurable func (srv *AggregationService) Schedule() { jobs := make(chan *AggregationJob) summaries := make(chan *models.Summary) @@ -58,7 +57,7 @@ func (srv *AggregationService) Schedule() { // Run once initially srv.trigger(jobs) - gocron.Every(1).Day().At("02:15").Do(srv.trigger, jobs) + gocron.Every(1).Day().At(srv.Config.App.AggregationTime).Do(srv.trigger, jobs) <-gocron.Start() }