Signed-off-by: dusk y.bera003.06@protonmail.com
+22
-3
appview/db/pulls.go
+22
-3
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 {
···
412
419
inClause := strings.TrimSuffix(strings.Repeat("?, ", len(pulls)), ", ")
413
420
submissionsQuery := fmt.Sprintf(`
414
421
select
415
-
id, pull_id, round_number, patch, source_rev
422
+
id, pull_id, round_number, patch, created, source_rev
416
423
from
417
424
pull_submissions
418
425
where
···
438
445
for submissionsRows.Next() {
439
446
var s PullSubmission
440
447
var sourceRev sql.NullString
448
+
var createdAt string
441
449
err := submissionsRows.Scan(
442
450
&s.ID,
443
451
&s.PullId,
444
452
&s.RoundNumber,
445
453
&s.Patch,
454
+
&createdAt,
446
455
&sourceRev,
447
456
)
448
457
if err != nil {
449
458
return nil, err
450
459
}
451
460
461
+
createdTime, err := time.Parse(time.RFC3339, createdAt)
462
+
if err != nil {
463
+
return nil, err
464
+
}
465
+
s.Created = createdTime
466
+
452
467
if sourceRev.Valid {
453
468
s.SourceRev = sourceRev.String
454
469
}
···
513
528
return orderedByPullId, nil
514
529
}
515
530
531
+
func GetPulls(e Execer, filters ...filter) ([]*Pull, error) {
532
+
return GetPullsWithLimit(e, 0, filters...)
533
+
}
534
+
516
535
func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {
517
536
query := `
518
537
select
History
3 rounds
5 comments
expand 1 comment
pull request successfully merged
expand 0 comments
expand 4 comments
why not use GetPulls with filters instead? we can additionally utilize things like comments and rounds in the feed.
right; i was going for no comments / rounds at first but that makes more sense!
(i think comments would be too noisy, thats best left to notifications IMO, but rounds would be fine)
removed that and modified GetPulls a bit and using that
submission created times were not being read from db, fixed