File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -1315,16 +1315,18 @@ func (c *Comment) HasOriginalAuthor() bool {
13151315 return c .OriginalAuthor != "" && c .OriginalAuthorID != 0
13161316}
13171317
1318+ func UpdateIssueNumCommentsBuilder (issueID int64 ) * builder.Builder {
1319+ subQuery := builder .Select ("COUNT(*)" ).From ("`comment`" ).Where (
1320+ builder.Eq {"issue_id" : issueID }.And (
1321+ builder .In ("`type`" , ConversationCountedCommentType ()),
1322+ ))
1323+
1324+ return builder .Update (builder.Eq {"num_comments" : subQuery }).
1325+ From ("`issue`" ).Where (builder.Eq {"id" : issueID })
1326+ }
1327+
13181328func UpdateIssueNumComments (ctx context.Context , issueID int64 ) error {
1319- countCommentsBuilder := builder .Select ("count(*)" ).From ("comment" ).Where (builder.Eq {
1320- "issue_id" : issueID ,
1321- }.And (builder .In ("type" , ConversationCountedCommentType ())))
1322-
1323- _ , err := db .GetEngine (ctx ).
1324- SetExpr ("num_comments" , countCommentsBuilder ).
1325- ID (issueID ).
1326- NoAutoTime ().
1327- Update (new (Issue ))
1329+ _ , err := db .GetEngine (ctx ).Exec (UpdateIssueNumCommentsBuilder (issueID ))
13281330 return err
13291331}
13301332
Original file line number Diff line number Diff line change @@ -639,6 +639,10 @@ func InsertReviews(ctx context.Context, reviews []*Review) error {
639639 return err
640640 }
641641 }
642+
643+ if err := UpdateIssueNumComments (ctx , review .IssueID ); err != nil {
644+ return err
645+ }
642646 }
643647
644648 return committer .Commit ()
Original file line number Diff line number Diff line change @@ -109,14 +109,7 @@ func userStatsCorrectNumRepos(ctx context.Context, id int64) error {
109109}
110110
111111func repoStatsCorrectIssueNumComments (ctx context.Context , id int64 ) error {
112- return StatsCorrectSQL (ctx ,
113- builder .Update (builder.Eq {
114- "num_comments" : builder .Select ("COUNT(*)" ).From ("`comment`" ).Where (
115- builder.Eq {"issue_id" : id }.And (
116- builder .In ("type" , issues_model .ConversationCountedCommentType ()),
117- )),
118- }).From ("`issue`" ).Where (builder.Eq {"id" : id }),
119- )
112+ return StatsCorrectSQL (ctx , issues_model .UpdateIssueNumCommentsBuilder (id ))
120113}
121114
122115func repoStatsCorrectNumIssues (ctx context.Context , id int64 ) error {
You can’t perform that action at this time.
0 commit comments