|
|
@@ -109,13 +109,8 @@ func (s *Storage) Categories(userID int64) (model.Categories, error) {
|
|
|
return categories, nil
|
|
|
}
|
|
|
|
|
|
-// CategoriesWithFeedCount returns all categories with the number of feeds.
|
|
|
-func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error) {
|
|
|
- user, err := s.UserByID(userID)
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
+// CategoriesWithFeedCount returns all categories with the number of feeds, sorted according to sortOrder.
|
|
|
+func (s *Storage) CategoriesWithFeedCount(userID int64, sortOrder string) (model.Categories, error) {
|
|
|
query := `
|
|
|
SELECT
|
|
|
c.id,
|
|
|
@@ -132,7 +127,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
|
|
|
user_id=$2
|
|
|
`
|
|
|
|
|
|
- if user.CategoriesSortingOrder == "alphabetical" {
|
|
|
+ if sortOrder == "alphabetical" {
|
|
|
query += `
|
|
|
ORDER BY
|
|
|
c.title ASC
|