cron filters give a warning when theres an error in var1

This commit is contained in:
BroodjeAap 2022-12-19 20:29:11 +00:00
parent e694853366
commit 01f3393968
2 changed files with 27 additions and 19 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/andybalholm/cascadia"
"github.com/antchfx/htmlquery"
"github.com/robfig/cron/v3"
"github.com/tidwall/gjson"
lualibs "github.com/vadv/gopher-lua-libs"
lua "github.com/yuin/gopher-lua"
@ -65,31 +66,32 @@ func processFilters(filters []Filter, web *Web, watch *Watch, debug bool, schedu
nextFilters := make([]*Filter, 0, len(currentFilters))
for i := range currentFilters {
filter := currentFilters[i]
if filter.Type == "store" {
if filter.Type == "store" {
storeFilters = append(storeFilters, filter)
processedMap[filter.ID] = true
continue
}
if debug && filter.Type == "cron" {
processedMap[filter.ID] = true
continue
}
if len(filter.Parents) == 0 && !debug {
continue
}
var allParentsProcessed = true
for _, parent := range filter.Parents {
if _, contains := processedMap[parent.ID]; !contains {
allParentsProcessed = false
break
if debug && filter.Type == "cron" {
processedMap[filter.ID] = true
getCronDebugResult(filter)
continue
}
}
if !allParentsProcessed {
if len(filter.Parents) == 0 && !debug {
continue
}
var allParentsProcessed = true
for _, parent := range filter.Parents {
if _, contains := processedMap[parent.ID]; !contains {
allParentsProcessed = false
break
}
}
if !allParentsProcessed {
nextFilters = append(nextFilters, filter)
continue
}
continue
}
getFilterResult(filters, filter, watch, web, debug)
processedMap[filter.ID] = true
processedMap[filter.ID] = true
}
if len(nextFilters) == 0 {
break
@ -850,6 +852,13 @@ func triggerSchedule(watchID uint, web *Web, scheduleID *uint) {
processFilters(filters, web, watch, false, scheduleID)
}
func getCronDebugResult(filter *Filter) {
_, err := cron.ParseStandard(filter.Var1)
if err != nil {
filter.log(err)
}
}
func getFilterResultLua(filter *Filter) {
L := lua.NewState()
defer L.Close()

View file

@ -11,5 +11,4 @@
- log things to db for cron runs
- comments
- db prune job
- add var1 parsing test for cron jobs
- add full buildFilterTree/processFilters test