mirror of
https://github.com/miniflux/v2.git
synced 2025-08-21 18:11:09 +00:00
parent
ec47106c26
commit
83e1f154b5
26 changed files with 131 additions and 13 deletions
|
@ -112,6 +112,11 @@ func (s *Storage) Categories(userID int64) (model.Categories, error) {
|
|||
|
||||
// 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
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
c.id,
|
||||
|
@ -126,11 +131,21 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
|
|||
FROM categories c
|
||||
WHERE
|
||||
user_id=$1
|
||||
ORDER BY
|
||||
count_unread DESC,
|
||||
c.title ASC
|
||||
`
|
||||
|
||||
if user.CategoriesSortOrder == "alphabetical" {
|
||||
query = query + `
|
||||
ORDER BY
|
||||
c.title ASC
|
||||
`
|
||||
} else {
|
||||
query = query + `
|
||||
ORDER BY
|
||||
count_unread DESC,
|
||||
c.title ASC
|
||||
`
|
||||
}
|
||||
|
||||
rows, err := s.db.Query(query, userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`store: unable to fetch categories: %v`, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue