feat(server): added proper filtering the BuildLog API

This commit is contained in:
Jef Roosens 2022-05-29 20:08:21 +02:00
parent 4f32dec5b5
commit a39c1aa5eb
Signed by untrusted user: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 40 additions and 14 deletions

View file

@ -35,7 +35,6 @@ pub mut:
repo int
before time.Time
after time.Time
exit_codes_whitelist []u8
exit_codes_blacklist []u8
arch string
exit_codes []string
}

View file

@ -1,5 +1,7 @@
module models
import time
// from_params<T> creates a new instance of T from the given map by parsing all
// of its fields from the map.
pub fn from_params<T>(params map[string]string) ?T {
@ -23,7 +25,12 @@ pub fn patch_from_params<T>(mut o T, params map[string]string) ? {
o.$(field.name) = params[field.name].u64()
} $else $if field.typ is []GitRepoArch {
o.$(field.name) = params[field.name].split(',').map(GitRepoArch{ value: it })
} $else $if field.typ is time.Time {
o.$(field.name) = time.unix(params[field.name].int())
} $else $if field.typ is []string {
o.$(field.name) = params[field.name].split(',')
}
} else if field.attrs.contains('nonull') {
return error('Missing parameter: ${field.name}.')
}