-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Move more functions to db.Find #28419
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d88c9f8
Move more functions to db.Find
lunny 2ce7fd0
More refactor
lunny bb5042f
more refactor
lunny 841c59b
fix import order
lunny 8d78985
Some refactors
lunny 3ee36be
Fix test
lunny 2b770cf
Merge branch 'main' into lunny/third_db_find
lunny 15288e3
Remove unused interface method
lunny 54ad0e7
fix lint
lunny c013275
Merge branch 'main' into lunny/third_db_find
lunny ade3860
Fix bug
lunny 680e8ab
Fix lint
lunny 24cd24a
Merge branch 'main' into lunny/third_db_find
lunny 6d0eb61
Merge branch 'main' into lunny/third_db_find
lunny a9654a3
Fix GPGList loading
lunny ba4e078
Merge branch 'lunny/third_db_find' of github.com:lunny/gitea into lun…
lunny 54e026e
remove unnsecessary parameter for AfterLoad
lunny bba80e6
Apply suggestions from code review
lunny ea830e6
Merge branch 'main' into lunny/third_db_find
lunny f8a31cc
Fix lint
lunny a59919f
Follow KN4CK3R's reviews
lunny 963bc9c
Merge branch 'main' into lunny/third_db_find
lunny 30106de
Merge branch 'main' into lunny/third_db_find
lunny a747e62
Merge branch 'main' into lunny/third_db_find
lunny 14289fa
Some improvements
lunny 8d541e2
Merge branch 'main' into lunny/third_db_find
lunny fca8d14
Merge branch 'main' into lunny/third_db_find
lunny 70614f5
Merge branch 'lunny/third_db_find' of github.com:lunny/gitea into lun…
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package asymkey | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
) | ||
|
||
type GPGKeyList []*GPGKey | ||
|
||
func (keys GPGKeyList) keyIDs() []string { | ||
ids := make([]string, len(keys)) | ||
for i, key := range keys { | ||
ids[i] = key.KeyID | ||
} | ||
return ids | ||
} | ||
|
||
func (keys GPGKeyList) LoadSubKeys(ctx context.Context) error { | ||
subKeys := make([]*GPGKey, 0, len(keys)) | ||
if err := db.GetEngine(ctx).In("primary_key_id", keys.keyIDs()).Find(&subKeys); err != nil { | ||
return err | ||
} | ||
subKeysMap := make(map[string][]*GPGKey, len(subKeys)) | ||
for _, key := range subKeys { | ||
subKeysMap[key.PrimaryKeyID] = append(subKeysMap[key.PrimaryKeyID], key) | ||
} | ||
|
||
for _, key := range keys { | ||
if subKeys, ok := subKeysMap[key.KeyID]; ok { | ||
key.SubsKey = subKeys | ||
} | ||
} | ||
return nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.