Skip to content

Commit 1b4b4b9

Browse files
committed
optimize if you can
1 parent 4a24bf1 commit 1b4b4b9

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

models/issue_reaction.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ func (opts *FindReactionsOptions) toConds() builder.Cond {
4848
}
4949

5050
//FindReactions returns Reactions based
51-
func FindReactions(opts FindReactionsOptions) (ReactionList, error) {
52-
return findReactions(x, opts)
51+
func FindReactions(comment *Comment) (ReactionList, error) {
52+
return findReactions(x, FindReactionsOptions{
53+
IssueID: comment.IssueID,
54+
CommentID: comment.ID})
5355
}
5456

5557
func findReactions(e Engine, opts FindReactionsOptions) (ReactionList, error) {

routers/api/v1/repo/issue_comment.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,6 @@ func GetCommentReactions(ctx *context.APIContext, form api.CommentReactionList)
428428
// responses:
429429
// "200":
430430
// "$ref": "#/responses/CommentReactions"
431-
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
432-
if err != nil {
433-
ctx.Error(500, "GetIssueByIndex", err)
434-
return
435-
}
436431
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
437432
if err != nil {
438433
if models.IsErrCommentNotExist(err) {
@@ -443,7 +438,7 @@ func GetCommentReactions(ctx *context.APIContext, form api.CommentReactionList)
443438
return
444439
}
445440

446-
rl, err := models.FindReactions(models.FindReactionsOptions{IssueID: issue.ID, CommentID: comment.ID})
441+
rl, err := models.FindReactions(comment)
447442
if err != nil {
448443
ctx.Error(500, "FindReactionsOptions", err)
449444
return

0 commit comments

Comments
 (0)