diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-20 22:08:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 22:08:52 +0800 |
commit | fd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch) | |
tree | 50038348ec10485f72344f3ac80324e04abc1283 /routers/api/v1/repo/pull_review.go | |
parent | d81e31ad7826a81fc7139f329f250594610a274b (diff) | |
download | gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip |
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context
* remove some unnecessary wrap functions
Diffstat (limited to 'routers/api/v1/repo/pull_review.go')
-rw-r--r-- | routers/api/v1/repo/pull_review.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go index 0cf540ce7e..5175fa921f 100644 --- a/routers/api/v1/repo/pull_review.go +++ b/routers/api/v1/repo/pull_review.go @@ -61,7 +61,7 @@ func ListPullReviews(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -87,7 +87,7 @@ func ListPullReviews(ctx *context.APIContext) { IssueID: pr.IssueID, } - allReviews, err := models.FindReviews(opts) + allReviews, err := models.FindReviews(ctx, opts) if err != nil { ctx.InternalServerError(err) return @@ -307,7 +307,7 @@ func CreatePullReview(ctx *context.APIContext) { // "$ref": "#/responses/validationError" opts := web.GetForm(ctx).(*api.CreatePullReviewOptions) - pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -526,7 +526,7 @@ func preparePullReviewType(ctx *context.APIContext, pr *models.PullRequest, even // prepareSingleReview return review, related pull and false or nil, nil and true if an error happen func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullRequest, bool) { - pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -536,7 +536,7 @@ func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullR return nil, nil, true } - review, err := models.GetReviewByID(ctx.ParamsInt64(":id")) + review, err := models.GetReviewByID(ctx, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrReviewNotExist(err) { ctx.NotFound("GetReviewByID", err) @@ -648,7 +648,7 @@ func DeleteReviewRequests(ctx *context.APIContext) { } func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions, isAdd bool) { - pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -676,7 +676,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions if strings.Contains(r, "@") { reviewer, err = user_model.GetUserByEmail(r) } else { - reviewer, err = user_model.GetUserByName(r) + reviewer, err = user_model.GetUserByName(ctx, r) } if err != nil { @@ -727,7 +727,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions teamReviewers := make([]*organization.Team, 0, len(opts.TeamReviewers)) for _, t := range opts.TeamReviewers { var teamReviewer *organization.Team - teamReviewer, err = organization.GetTeam(ctx.Repo.Owner.ID, t) + teamReviewer, err = organization.GetTeam(ctx, ctx.Repo.Owner.ID, t) if err != nil { if organization.IsErrTeamNotExist(err) { ctx.NotFound("TeamNotExist", fmt.Sprintf("Team '%s' not exist", t)) @@ -892,7 +892,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss bool) { return } - if review, err = models.GetReviewByID(review.ID); err != nil { + if review, err = models.GetReviewByID(ctx, review.ID); err != nil { ctx.Error(http.StatusInternalServerError, "GetReviewByID", err) return } |