Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Signed-off-by: dusk <y.bera003.06@protonmail.com>

authored by

dusk and committed by
Tangled
f5917160 b3ce5aec

+22 -3
+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 ··· 323 323 whereClause := "" 324 324 if conditions != nil { 325 325 whereClause = " where " + strings.Join(conditions, " and ") 326 + } 327 + limitClause := "" 328 + if limit != 0 { 329 + limitClause = fmt.Sprintf(" limit %d ", limit) 326 330 } 327 331 328 332 query := fmt.Sprintf(` ··· 348 344 from 349 345 pulls 350 346 %s 351 - `, whereClause) 347 + order by 348 + created desc 349 + %s 350 + `, whereClause, limitClause) 352 351 353 352 rows, err := e.Query(query, args...) 354 353 if err != nil { ··· 419 412 inClause := strings.TrimSuffix(strings.Repeat("?, ", len(pulls)), ", ") 420 413 submissionsQuery := fmt.Sprintf(` 421 414 select 422 - id, pull_id, round_number, patch, source_rev 415 + id, pull_id, round_number, patch, created, source_rev 423 416 from 424 417 pull_submissions 425 418 where ··· 445 438 for submissionsRows.Next() { 446 439 var s PullSubmission 447 440 var sourceRev sql.NullString 441 + var createdAt string 448 442 err := submissionsRows.Scan( 449 443 &s.ID, 450 444 &s.PullId, 451 445 &s.RoundNumber, 452 446 &s.Patch, 447 + &createdAt, 453 448 &sourceRev, 454 449 ) 455 450 if err != nil { 456 451 return nil, err 457 452 } 453 + 454 + createdTime, err := time.Parse(time.RFC3339, createdAt) 455 + if err != nil { 456 + return nil, err 457 + } 458 + s.Created = createdTime 458 459 459 460 if sourceRev.Valid { 460 461 s.SourceRev = sourceRev.String ··· 526 511 }) 527 512 528 513 return orderedByPullId, nil 514 + } 515 + 516 + func GetPulls(e Execer, filters ...filter) ([]*Pull, error) { 517 + return GetPullsWithLimit(e, 0, filters...) 529 518 } 530 519 531 520 func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*Pull, error) {