Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue comment number #30556

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 18, 2024

Fix #22419

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 18, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 18, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 18, 2024
@silverwind silverwind added the backport/v1.22 This PR should be backported to Gitea 1.22 label Apr 18, 2024
@silverwind
Copy link
Member

silverwind commented Apr 19, 2024

How much work would it be to add a migration that fixes the counts on existing issues? Would probably be a long-running migration on big instances, right?

Also, not sure if such a migration would be backportable at all as it would likely skip migration numbers (a design flaw in the migration system).

@lunny
Copy link
Member Author

lunny commented Apr 19, 2024

How much work would it be to add a migration that fixes the counts on existing issues? Would probably be a long-running migration on big instances, right?

Yes, so I don't think the migration is necessary. The number will be corrected when next comment created/updated.

Also, not sure if such a migration would be backportable at all as it would likely skip migration numbers (a design flaw in the migration system).

@silverwind
Copy link
Member

Yeah it's not really a requirement from me, more like a "nice to have" but likely too complicated with the migration backport to really be justified.

@silverwind
Copy link
Member

Willing to approve this without migration once you fix the tests :)

func CountCommentsBuilder(issueID int64) *builder.Builder {
return builder.Select("count(*)").From("comment").Where(builder.Eq{
"issue_id": issueID,
}.And(builder.Or(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be converted into In?

@@ -109,7 +109,7 @@ func userStatsCorrectNumRepos(ctx context.Context, id int64) error {
}

func repoStatsCorrectIssueNumComments(ctx context.Context, id int64) error {
return StatsCorrectSQL(ctx, "UPDATE `issue` SET num_comments=(SELECT COUNT(*) FROM `comment` WHERE issue_id=? AND type=0) WHERE id=?", id)
return StatsCorrectSQL(ctx, "UPDATE `issue` SET num_comments=(SELECT COUNT(*) FROM `comment` WHERE issue_id=? AND (type=0 or type=22)) WHERE id=?", id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type=0 or type=22

use variable instead of number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v1.22 This PR should be backported to Gitea 1.22 lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source code line's comments are not taken into account on Pull Requests page
4 participants