appview: db: pulls: add method for getting any pulls on a repo #475

merged
opened by ptr.pet targeting master from ptr.pet/core: repo-feed
Changed files
+13 -2
appview
+13 -2
appview/db/pulls.go
···
return pullId - 1, err
}
-
func GetPulls(e Execer, filters ...filter) ([]*Pull, error) {
+
func GetPullsWithLimit(e Execer, limit int, filters ...filter) ([]*Pull, error) {
pulls := make(map[int]*Pull)
var conditions []string
···
if conditions != nil {
whereClause = " where " + strings.Join(conditions, " and ")
}
+
limitClause := ""
+
if limit != 0 {
+
limitClause = fmt.Sprintf(" limit %d ", limit)
+
}
query := fmt.Sprintf(`
select
···
from
pulls
%s
-
`, whereClause)
+
order by
+
created desc
+
%s
+
`, whereClause, limitClause)
rows, err := e.Query(query, args...)
if err != nil {
···
return orderedByPullId, nil
}
+
func GetPulls(e Execer, filters ...filter) ([]*Pull, error) {
+
return GetPullsWithLimit(e, 0, filters...)
+
}
+
func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
query := `
select