The Wayback Machine - https://web.archive.org/web/20220215125750/https://github.com/go-gitea/gitea/pull/17100
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

DBContext is just a Context #17100

Merged
merged 8 commits into from Sep 23, 2021
Merged

DBContext is just a Context #17100

merged 8 commits into from Sep 23, 2021

Conversation

@zeripath
Copy link
Contributor

@zeripath zeripath commented Sep 20, 2021

This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.

Signed-off-by: Andrew Thornton [email protected]

This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath zeripath added this to the 1.16.0 milestone Sep 20, 2021
@lafriks
Copy link
Member

@lafriks lafriks commented Sep 20, 2021

unit tests fail

@codecov-commenter
Copy link

@codecov-commenter codecov-commenter commented Sep 22, 2021

Codecov Report

Merging #17100 (6b87fc2) into main (f2e7d54) will increase coverage by 0.00%.
The diff coverage is 62.42%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17100   +/-   ##
=======================================
  Coverage   45.31%   45.31%           
=======================================
  Files         773      773           
  Lines       86873    86907   +34     
=======================================
+ Hits        39366    39382   +16     
- Misses      41151    41163   +12     
- Partials     6356     6362    +6     
Impacted Files Coverage Δ
models/action.go 48.86% <0.00%> (ø)
models/avatar.go 35.38% <0.00%> (ø)
models/fixture_generation.go 70.00% <0.00%> (ø)
models/gpg_key_verify.go 13.46% <0.00%> (ø)
models/issue_lock.go 0.00% <0.00%> (ø)
models/list_options.go 77.14% <0.00%> (ø)
models/migrate.go 0.00% <0.00%> (ø)
models/oauth2.go 27.27% <0.00%> (ø)
models/repo_archiver.go 6.25% <0.00%> (ø)
models/repo_generate.go 15.00% <0.00%> (ø)
... and 116 more

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 f2e7d54...6b87fc2. Read the comment docs.

models/attachment.go Outdated Show resolved Hide resolved
stats.Counter.PublicKey, _ = db.GetEngine(db.DefaultContext).Count(new(PublicKey))
stats.Counter.Repo = CountRepositories(true)
stats.Counter.Watch, _ = db.DefaultContext().Engine().Count(new(Watch))
stats.Counter.Star, _ = db.DefaultContext().Engine().Count(new(Star))
stats.Counter.Action, _ = db.DefaultContext().Engine().Count(new(Action))
stats.Counter.Access, _ = db.DefaultContext().Engine().Count(new(Access))
stats.Counter.Watch, _ = db.GetEngine(db.DefaultContext).Count(new(Watch))
stats.Counter.Star, _ = db.GetEngine(db.DefaultContext).Count(new(Star))
stats.Counter.Action, _ = db.GetEngine(db.DefaultContext).Count(new(Action))
stats.Counter.Access, _ = db.GetEngine(db.DefaultContext).Count(new(Access))
Copy link
Member

@KN4CK3R KN4CK3R Sep 22, 2021

Choose a reason for hiding this comment

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

Could introduce a variable to reduce the calls.

Copy link
Contributor Author

@zeripath zeripath Sep 23, 2021

Choose a reason for hiding this comment

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

As you might imagine, the code was a result of a mass find and replace.

Copy link
Member

@KN4CK3R KN4CK3R Sep 23, 2021

Choose a reason for hiding this comment

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

Sure, but could be changed while working at it.

lunny
lunny approved these changes Sep 23, 2021
@lunny
Copy link
Member

@lunny lunny commented Sep 23, 2021

Please resolve the conflicts.

@zeripath
Copy link
Contributor Author

@zeripath zeripath commented Sep 23, 2021

make lgtm work

@lunny lunny merged commit 9302eba into go-gitea:main Sep 23, 2021
2 checks passed
@zeripath zeripath deleted the db-context-is-a-context branch Sep 23, 2021
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants