Signed-off-by: dusk y.bera003.06@protonmail.com
+13
-2
appview/db/pulls.go
+13
-2
appview/db/pulls.go
···
310
return pullId - 1, err
311
}
312
313
-
func GetPulls(e Execer, filters ...filter) ([]*Pull, error) {
314
pulls := make(map[int]*Pull)
315
316
var conditions []string
···
324
if conditions != nil {
325
whereClause = " where " + strings.Join(conditions, " and ")
326
}
327
328
query := fmt.Sprintf(`
329
select
···
344
from
345
pulls
346
%s
347
-
`, whereClause)
348
349
rows, err := e.Query(query, args...)
350
if err != nil {
···
513
return orderedByPullId, nil
514
}
515
516
func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
517
query := `
518
select
···
310
return pullId - 1, err
311
}
312
313
+
func GetPullsWithLimit(e Execer, limit int, filters ...filter) ([]*Pull, error) {
314
pulls := make(map[int]*Pull)
315
316
var conditions []string
···
324
if conditions != nil {
325
whereClause = " where " + strings.Join(conditions, " and ")
326
}
327
+
limitClause := ""
328
+
if limit != 0 {
329
+
limitClause = fmt.Sprintf(" limit %d ", limit)
330
+
}
331
332
query := fmt.Sprintf(`
333
select
···
348
from
349
pulls
350
%s
351
+
order by
352
+
created desc
353
+
%s
354
+
`, whereClause, limitClause)
355
356
rows, err := e.Query(query, args...)
357
if err != nil {
···
520
return orderedByPullId, nil
521
}
522
523
+
func GetPulls(e Execer, filters ...filter) ([]*Pull, error) {
524
+
return GetPullsWithLimit(e, 0, filters...)
525
+
}
526
+
527
func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
528
query := `
529
select