Commit e0bb4c95 authored by zauberstuhl's avatar zauberstuhl

Optimize regexp and map loop

parent b3cd12c7
Pipeline #765 passed with stage
in 1 minute and 17 seconds
......@@ -83,17 +83,20 @@ func reportsBadge(fqdn, slug string, w http.ResponseWriter, r *http.Request) {
}
var success, fail, skip int
reSkip := regexp.MustCompile(`^ok.*#\sskip`)
reOk := regexp.MustCompile(`^ok`)
reNot := regexp.MustCompile(`^not`)
for _, report := range reports {
for _, line := range strings.Split(report, "\n") {
if m, err := regexp.MatchString(`^ok.*#\sskip`, line); m && err == nil {
if reSkip.MatchString(line) {
skip += 1
continue
}
if m, err := regexp.MatchString(`^ok`, line); m && err == nil {
if reOk.MatchString(line) {
success += 1
continue
}
if m, err := regexp.MatchString(`^not`, line); m && err == nil {
if reNot.MatchString(line) {
fail += 1
continue
}
......
......@@ -78,7 +78,7 @@ func buildsPNG(w http.ResponseWriter, r *http.Request) {
// sort
var keys sortTime
for key, _ := range statesPerDay {
for key := range statesPerDay {
keys = append(keys, key)
}
sort.Sort(keys)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment