created watches from templates/url/file also have their schedules started

This commit is contained in:
BroodjeAap 2023-01-23 17:56:40 +00:00
parent c2e1a29c3d
commit 98305d3ccf

17
main.go
View file

@ -556,6 +556,23 @@ func (web *Web) watchCreatePost(c *gin.Context) {
}
}
for i := range export.Filters {
cronFilter := &export.Filters[i]
if cronFilter.Type != "cron" {
continue
}
if cronFilter.Var2 != nil && *cronFilter.Var2 == "no" {
continue
}
entryID, err := web.cron.AddFunc(cronFilter.Var1, func() { triggerSchedule(cronFilter.WatchID, web, &cronFilter.ID) })
if err != nil {
log.Println("Could not start job for Watch: ", cronFilter.WatchID)
continue
}
log.Println("Started CronJob for WatchID", cronFilter.WatchID, "with schedule:", cronFilter.Var1)
web.cronWatch[cronFilter.ID] = entryID
}
// we again set all the connection.ID to 0,
// but then also swap the old filterIDs to the new IDs the filters got after db.Create
for i := range export.Connections {