MCPcopy
hub / github.com/harness/harness / Stream

Method Stream

app/store/database/pullreq.go:514–559  ·  view source on GitHub ↗

Stream returns a list of pull requests for a repo.

(ctx context.Context, opts *types.PullReqFilter)

Source from the content-addressed store, hash-verified

512
513// Stream returns a list of pull requests for a repo.
514func (s *PullReqStore) Stream(ctx context.Context, opts *types.PullReqFilter) (<-chan *types.PullReq, <-chan error) {
515 stmt := s.listQuery(opts)
516
517 stmt = stmt.OrderBy("pullreq_updated desc")
518
519 chPRs := make(chan *types.PullReq)
520 chErr := make(chan error, 1)
521
522 go func() {
523 defer close(chPRs)
524 defer close(chErr)
525
526 sql, args, err := stmt.ToSql()
527 if err != nil {
528 chErr <- fmt.Errorf("failed to convert query to sql: %w", err)
529 return
530 }
531
532 db := dbtx.GetAccessor(ctx, s.db)
533
534 rows, err := db.QueryxContext(ctx, sql, args...)
535 if err != nil {
536 chErr <- database.ProcessSQLErrorf(ctx, err, "Failed to execute stream query")
537 return
538 }
539
540 defer func() { _ = rows.Close() }()
541
542 for rows.Next() {
543 var prData pullReq
544 err = rows.StructScan(&prData)
545 if err != nil {
546 chErr <- fmt.Errorf("failed to scan pull request: %w", err)
547 return
548 }
549
550 chPRs <- s.mapPullReq(ctx, &prData)
551 }
552
553 if err := rows.Err(); err != nil {
554 chErr <- fmt.Errorf("failed to scan pull request: %w", err)
555 }
556 }()
557
558 return chPRs, chErr
559}
560
561func (s *PullReqStore) ListOpenByBranchName(
562 ctx context.Context,

Callers

nothing calls this directly

Implementers 1

PullReqStoreapp/store/database/pullreq.go

Calls 9

listQueryMethod · 0.95
mapPullReqMethod · 0.95
GetAccessorFunction · 0.92
ProcessSQLErrorfFunction · 0.92
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
ErrorfMethod · 0.45
QueryxContextMethod · 0.45

Tested by

no test coverage detected