Stop depending on magic numbers in database #813

Closed
opened 2025-11-02 03:37:36 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @bkcsoft on GitHub (Jun 15, 2017).

Sparking from https://github.com/go-gitea/gitea/issues/1937

The reason we have repository.num_issues isn't to know how many issues there are, but to know what issue-number to assign next. It should not be used in the UI to list number of issues 🙄

Originally created by @bkcsoft on GitHub (Jun 15, 2017). Sparking from https://github.com/go-gitea/gitea/issues/1937 The reason we have `repository.num_issues` isn't to know how many issues there are, but to know what issue-number to assign next. It should _not_ be used in the UI to list number of issues 🙄
GiteaMirror added the type/proposal label 2025-11-02 03:37:36 -06:00
Author
Owner

@uncled1023 commented on GitHub (Dec 19, 2017):

Is this still an issue?

@uncled1023 commented on GitHub (Dec 19, 2017): Is this still an issue?
Author
Owner

@lafriks commented on GitHub (Dec 19, 2017):

For count we should probably could use cache like I changed it in commit count

@lafriks commented on GitHub (Dec 19, 2017): For count we should probably could use cache like I changed it in commit count
Author
Owner

@uncled1023 commented on GitHub (Jan 27, 2018):

In kind of a related note, is there a method to 'reset' the issue counts? ie: num_issues

@uncled1023 commented on GitHub (Jan 27, 2018): In kind of a related note, is there a method to 'reset' the issue counts? ie: num_issues
Author
Owner

@bkcsoft commented on GitHub (Feb 10, 2018):

@uncled1023 As far as I know, no. The only way is to open up the database and run a query. Do note that count(...) will break things, as num_issues is used to select the number for the next opened issue or pull-request 😒 (That also needs to be fixed 😉 )

@bkcsoft commented on GitHub (Feb 10, 2018): @uncled1023 As far as I know, no. The only way is to open up the database and run a query. Do note that `count(...)` will break things, as `num_issues` is used to select the number for the next opened issue or pull-request 😒 (That also needs to be fixed 😉 )
Author
Owner

@sapk commented on GitHub (Jan 16, 2020):

I don't think this is still the case but I will have to re-check

@sapk commented on GitHub (Jan 16, 2020): I don't think this is still the case but I will have to re-check
Author
Owner

@guillep2k commented on GitHub (Jan 16, 2020):

I don't think this is still the case but I will have to re-check

@sapk I can confirm it's not the case.

@guillep2k commented on GitHub (Jan 16, 2020): > > > I don't think this is still the case but I will have to re-check @sapk I can confirm it's not the case.
Author
Owner

@guillep2k commented on GitHub (Jan 16, 2020):

Here's the code used to assign the issue number (index) nowadays:

cc2916dc5a/models/issue.go (L901-L905)

Not to say it can't be improved. 😄

@guillep2k commented on GitHub (Jan 16, 2020): Here's the code used to assign the issue number (index) nowadays: https://github.com/go-gitea/gitea/blob/cc2916dc5acea2c32372082986f8c2e2c43e55fe/models/issue.go#L901-L905 Not to say it can't be improved. 😄
Author
Owner

@sapk commented on GitHub (Jan 16, 2020):

Thanks to confirm that. I will close this issue so.

@sapk commented on GitHub (Jan 16, 2020): Thanks to confirm that. I will close this issue so.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#813