1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: make aggregation time configurable (resolve #60)

This commit is contained in:
Ferdinand Mütsch 2020-10-16 16:21:13 +02:00
parent a4c344aaa1
commit 177cbb12fc
3 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@ server:
app: app:
cleanup: false # only edit, if you know what you're doing 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: custom_languages:
vue: Vue vue: Vue
jsx: JSX jsx: JSX

View File

@ -27,6 +27,7 @@ var (
type appConfig struct { type appConfig struct {
CleanUp bool `default:"false" env:"WAKAPI_CLEANUP"` 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"` CustomLanguages map[string]string `yaml:"custom_languages"`
LanguageColors map[string]string `yaml:"-"` LanguageColors map[string]string `yaml:"-"`
} }

View File

@ -40,7 +40,6 @@ type AggregationJob struct {
} }
// Schedule a job to (re-)generate summaries every day shortly after midnight // Schedule a job to (re-)generate summaries every day shortly after midnight
// TODO: Make configurable
func (srv *AggregationService) Schedule() { func (srv *AggregationService) Schedule() {
jobs := make(chan *AggregationJob) jobs := make(chan *AggregationJob)
summaries := make(chan *models.Summary) summaries := make(chan *models.Summary)
@ -58,7 +57,7 @@ func (srv *AggregationService) Schedule() {
// Run once initially // Run once initially
srv.trigger(jobs) 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() <-gocron.Start()
} }