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