refactor: reduce sql query in retrieveFeeds (#3547)

This commit is contained in:
Bo-Yi Wu authored and GitHub committed 2018-02-21 18:55:34 +08:00
1 parent d27d720f05
commit 04b3e8cbdc
3 files changed
+118 -34

No files matched your search

+10 -1
View File
@@ -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
}