snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
56
server/pkg/ql/util.go
Normal file
56
server/pkg/ql/util.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package ql
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
truthy = regexp.MustCompile(`^(t(rue)?|y(es)?|1)$`)
|
||||
)
|
||||
|
||||
// Check what boolean value the given string conforms to
|
||||
func evalBool(v string) bool {
|
||||
return truthy.MatchString(strings.ToLower(v))
|
||||
}
|
||||
|
||||
// Check if the given string is a float
|
||||
func isFloaty(v string) bool {
|
||||
return strings.Contains(v, ".")
|
||||
}
|
||||
|
||||
func MergeAnd(a, b *ASTNode) *ASTNode {
|
||||
return merger(a, b, "and")
|
||||
}
|
||||
|
||||
func MergeOr(a, b *ASTNode) *ASTNode {
|
||||
return merger(a, b, "or")
|
||||
}
|
||||
|
||||
func merger(a, b *ASTNode, ref string) *ASTNode {
|
||||
// 1. merge the two
|
||||
aa := make(ASTNodeSet, 0, 2)
|
||||
|
||||
// It needs to be under a group, so we get an `(a) and/or (b)`
|
||||
if a != nil {
|
||||
aa = append(aa, &ASTNode{Ref: "group", Args: ASTNodeSet{a}})
|
||||
}
|
||||
if b != nil {
|
||||
aa = append(aa, &ASTNode{Ref: "group", Args: ASTNodeSet{b}})
|
||||
}
|
||||
|
||||
// 2. flatten
|
||||
// @todo do some more in-depth processing?
|
||||
if len(aa) == 1 {
|
||||
// this [0][0] will always hold if we get to this point
|
||||
return aa[0].Args[0]
|
||||
}
|
||||
if len(aa) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &ASTNode{
|
||||
Ref: ref,
|
||||
Args: aa,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user