···168168169169// this is a mega query, but the most useful one:170170// get N pipelines, for each one get the latest status of its N workflows171171-func GetPipelineStatuses(e Execer, filters ...filter) ([]models.Pipeline, error) {171171+func GetPipelineStatuses(e Execer, limit int, filters ...filter) ([]models.Pipeline, error) {172172 var conditions []string173173 var args []any174174 for _, filter := range filters {···205205 join206206 triggers t ON p.trigger_id = t.id207207 %s208208- `, whereClause)208208+ order by p.created desc209209+ limit %d210210+ `, whereClause, limit)209211210212 rows, err := e.Query(query, args...)211213 if err != nil {
···11package repo2233import (44- "crypto/rand"55- "math/big"64 "slices"75 "sort"86 "strings"···8890 return8991}90929191-func randomString(n int) string {9292- const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"9393- result := make([]byte, n)9494-9595- for i := 0; i < n; i++ {9696- n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))9797- result[i] = letters[n.Int64()]9898- }9999-100100- return string(result)101101-}102102-10393// grab pipelines from DB and munge that into a hashmap with commit sha as key10494//10595// golang is so blessed that it requires 35 lines of imperative code for this···104118105119 ps, err := db.GetPipelineStatuses(106120 d,121121+ len(shas),107122 db.FilterEq("repo_owner", repoInfo.OwnerDid),108123 db.FilterEq("repo_name", repoInfo.Name),109124 db.FilterEq("knot", repoInfo.Knot),