-
Notifications
You must be signed in to change notification settings - Fork 145
/
list_pull_requests.go
41 lines (31 loc) · 1.13 KB
/
list_pull_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package workflows
import (
"github.com/labstack/echo/v4"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/gen"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/transformers"
"github.com/hatchet-dev/hatchet/internal/repository"
"github.com/hatchet-dev/hatchet/internal/repository/prisma/db"
)
func (t *WorkflowService) WorkflowRunListPullRequests(ctx echo.Context, request gen.WorkflowRunListPullRequestsRequestObject) (gen.WorkflowRunListPullRequestsResponseObject, error) {
workflowRun := ctx.Get("workflow-run").(*db.WorkflowRunModel)
listOpts := &repository.ListPullRequestsForWorkflowRunOpts{}
if request.Params.State != nil {
listOpts.State = repository.StringPtr(string(*request.Params.State))
}
prs, err := t.config.APIRepository.WorkflowRun().ListPullRequestsForWorkflowRun(
workflowRun.TenantID,
workflowRun.ID,
listOpts,
)
if err != nil {
return nil, err
}
rows := make([]gen.PullRequest, 0)
for _, pr := range prs {
prCp := pr
rows = append(rows, *transformers.ToPullRequest(&prCp))
}
return gen.WorkflowRunListPullRequests200JSONResponse(gen.ListPullRequestsResponse{
PullRequests: rows,
}), nil
}