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 stats upon searching issues #17566

Merged
merged 4 commits into from
Nov 8, 2021
Merged

Conversation

Gusted
Copy link
Contributor

@Gusted Gusted commented Nov 6, 2021

  • Fixes a issue whereby the given chunk of issueIDs wasn't respected and
    thus the returned results where not the correct results. More specifically when the amount of returned results are above maxQueryParameters.

To reproduce this issue easily:

  • Set the constant maxQueryParameters within the code to a value of 5.
  • Create a new repo.
  • Create more than 5 issues(I'm using 7) with the same description(e.g. Hello).
  • Go to the issues tab and search for that description: Hello.
  • See that amount of open issues is inaccurate and way above the correct amount.

^ This PR fixes that issue.

Their is a interesting comment above the relevant code:

gitea/models/issue.go

Lines 1502 to 1505 in bd613c7

// If too long a list of IDs is provided, we get the statistics in
// smaller chunks and get accumulates. Note: this could potentially
// get us invalid results. The alternative is to insert the list of
// ids in a temporary table and join from them.

I do think that the person writing that comment was hitting into this bug whereby the wrong issuesIDs were used in the database action and I do think it can be removed, but I'm not sure.

Screenshots(The repo had 7 issues with the description of Helo):

Before:
image

After:
image

- Fixes a issue whereby the given chunk of issueIDs wasn't respected and
thus the returned results where not the correct results.
@lunny lunny added the type/bug label Nov 6, 2021
@lunny
Copy link
Member

lunny commented Nov 6, 2021

Could you add some tests?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 6, 2021
@Gusted
Copy link
Contributor Author

Gusted commented Nov 6, 2021

Could you add some tests?

Done.

@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@d168f04). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17566   +/-   ##
=======================================
  Coverage        ?   45.51%           
=======================================
  Files           ?      793           
  Lines           ?    88846           
  Branches        ?        0           
=======================================
  Hits            ?    40439           
  Misses          ?    41891           
  Partials        ?     6516           
Impacted Files Coverage Δ
models/issue.go 59.37% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d168f04...23df719. Read the comment docs.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 7, 2021
@lunny
Copy link
Member

lunny commented Nov 7, 2021

Maybe this should be backport to v1.15

Gusted pushed a commit to Gusted/gitea that referenced this pull request Nov 7, 2021
@Gusted
Copy link
Contributor Author

Gusted commented Nov 7, 2021

Maybe this should be backport to v1.15

#17578

@lunny lunny added the backport/done All backports for this PR have been created label Nov 8, 2021
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 8, 2021
@lafriks lafriks merged commit a3f9e92 into go-gitea:main Nov 8, 2021
lafriks pushed a commit that referenced this pull request Nov 8, 2021
- Backport of #17566

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
@wxiaoguang wxiaoguang added this to the 1.16.0 milestone Nov 22, 2021
@Gusted Gusted deleted the fix-search-chunk branch November 24, 2021 08:26
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
* Fix stat chunks searching

- Fixes a issue whereby the given chunk of issueIDs wasn't respected and
thus the returned results where not the correct results.

* Add tests

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants