search: add localOnly to web app queries, fix string+bool queries

localOnly: true in a queryType means it won't be sent to the server, but
will be evaluated by the web app on the returned search results.
This commit is contained in:
Harvey Tindall
2025-05-26 16:06:41 +01:00
parent 9715f90a48
commit ef253de56b
4 changed files with 104 additions and 32 deletions
+26 -4
View File
@@ -306,16 +306,38 @@ func (q QueryDTO) AsFilter() Filter {
return cmp.Compare(bool2int(a.NotifyThroughEmail), bool2int(q.Value.(bool))) == int(operator)
}
case "last_active":
return func(a *respUser) bool {
return q.Value.(DateAttempt).CompareUnix(a.LastActive) == int(operator)
switch q.Class {
case DateQuery:
return func(a *respUser) bool {
return q.Value.(DateAttempt).CompareUnix(a.LastActive) == int(operator)
}
case BoolQuery:
return func(a *respUser) bool {
val := a.LastActive != 0
if q.Value.(bool) == false {
val = !val
}
return val
}
}
case "admin":
return func(a *respUser) bool {
return cmp.Compare(bool2int(a.Admin), bool2int(q.Value.(bool))) == int(operator)
}
case "expiry":
return func(a *respUser) bool {
return q.Value.(DateAttempt).CompareUnix(a.Expiry) == int(operator)
switch q.Class {
case DateQuery:
return func(a *respUser) bool {
return q.Value.(DateAttempt).CompareUnix(a.Expiry) == int(operator)
}
case BoolQuery:
return func(a *respUser) bool {
val := a.Expiry != 0
if q.Value.(bool) == false {
val = !val
}
return val
}
}
case "disabled":
return func(a *respUser) bool {