diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2018-02-21 18:55:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-21 18:55:34 +0800 |
commit | 04b3e8cbdc2bb4eafe8feb3fe4882f010e931860 (patch) | |
tree | ca463be266c44aaf52e5106aac77dfd56402057b /models/action.go | |
parent | d27d720f05835dfc4633587aec885ab9b93b5f86 (diff) | |
download | gitea-04b3e8cbdc2bb4eafe8feb3fe4882f010e931860.tar.gz gitea-04b3e8cbdc2bb4eafe8feb3fe4882f010e931860.zip |
refactor: reduce sql query in retrieveFeeds (#3547)
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/models/action.go b/models/action.go index 5333f62772..b551d79bb8 100644 --- a/models/action.go +++ b/models/action.go @@ -742,5 +742,14 @@ func GetFeeds(opts GetFeedsOptions) ([]*Action, error) { } actions := make([]*Action, 0, 20) - return actions, x.Limit(20).Desc("id").Where(cond).Find(&actions) + + if err := x.Limit(20).Desc("id").Where(cond).Find(&actions); err != nil { + return nil, fmt.Errorf("Find: %v", err) + } + + if err := ActionList(actions).LoadAttributes(); err != nil { + return nil, fmt.Errorf("LoadAttributes: %v", err) + } + + return actions, nil } |