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 empty repo updated time #33120

Merged
merged 6 commits into from
Jan 6, 2025

Conversation

changchaishi
Copy link
Contributor

fixes #33119

routers/web/repo/view_home.go
image

Calling updateContextRepoEmptyAndStatus will always ask the DB to update the updated Unix attributes.
When revisiting the repo's home page, the timestamp will be updated unexpectedly, so I added the needsUpdate variable to check whether, in the end, the commitment to db update is necessary if columns have not changed at all.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 6, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jan 6, 2025
@lunny
Copy link
Member

lunny commented Jan 6, 2025

Since it's not a real update, we should use xorm's NoAutoTime to update the record to avoid updated time change.

@pull-request-size pull-request-size bot added size/XS and removed size/S labels Jan 6, 2025
@changchaishi
Copy link
Contributor Author

Hi @lunny,

I have three scenarios in mind:

  1. Use NoAutoTime from an extra parameter UpdateRepositoryCols, but there are 23 calls to this function to the codebase.
  2. Add a new function like UpdateRepositoryColsNoAutoTime <- something like this
  3. Stick with current fix. Will this save the DB round trip?
  4. Access DB directly from updateContextRepoEmptyAndStatus, least code change and it is like combination of 2 and 3

I updated the code to use 4. Please review if this is ok.

@lunny
Copy link
Member

lunny commented Jan 6, 2025

Hi @lunny,

I have three scenarios in mind:

1. Use `NoAutoTime` from an extra parameter `UpdateRepositoryCols`, but there are 23 calls to this function to the codebase.

2. Add a new function like `UpdateRepositoryColsNoAutoTime` <- something like this

3. Stick with current fix. Will this save the DB round trip?

4. Access DB directly from `updateContextRepoEmptyAndStatus`, least code change and it is like combination of 2 and 3

I updated the code to use 4. Please review if this is ok.

I prefer solution 2.

@pull-request-size pull-request-size bot added size/S and removed size/XS labels Jan 6, 2025
@changchaishi changchaishi force-pushed the fix-empty-repo-updated-time branch from 4ff1c86 to c0d9408 Compare January 6, 2025 08:38
@pull-request-size pull-request-size bot added size/XS and removed size/S labels Jan 6, 2025
@changchaishi
Copy link
Contributor Author

Updated.

@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 Jan 6, 2025
@pull-request-size pull-request-size bot added size/S and removed size/XS labels Jan 6, 2025
@wxiaoguang wxiaoguang added the backport/v1.23 This PR should be backported to Gitea 1.23 label Jan 6, 2025
@wxiaoguang wxiaoguang added this to the 1.24.0 milestone Jan 6, 2025
@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 Jan 6, 2025
@lunny lunny merged commit 1a95d9d into go-gitea:main Jan 6, 2025
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Jan 6, 2025
fixes go-gitea#33119 

routers/web/repo/view_home.go

![image](https://github.com/user-attachments/assets/b0d6c5f5-7abc-478a-8d41-4b44dbd460aa)

Calling `updateContextRepoEmptyAndStatus` will always ask the DB to
update the updated Unix attributes.
When revisiting the repo's home page, the timestamp will be updated
unexpectedly, so I added the needsUpdate variable to check whether, in
the end, the commitment to db update is necessary if columns have not
changed at all.

---------

Co-authored-by: wxiaoguang <[email protected]>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Jan 6, 2025
wxiaoguang added a commit that referenced this pull request Jan 6, 2025
Backport #33120 by changchaishi

fixes #33119 


Co-authored-by: Chai-Shi <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jan 7, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Remove extended glob pattern from branch protection UI (go-gitea#33125)
  fix empty repo updated time (go-gitea#33120)
  Refactor package (routes and error handling, npm peer dependency) (go-gitea#33111)
  Refactor legacy JS (go-gitea#33115)
  Fix repo empty guide (go-gitea#33114)
@changchaishi changchaishi deleted the fix-empty-repo-updated-time branch January 7, 2025 02:01
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Apr 6, 2025
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 backport/v1.23 This PR should be backported to Gitea 1.23 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revisit empty repo will always update the repo's timestamp
6 participants