Skip to content
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

Use variables for the status in the entries table #2212

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/storage/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
(SELECT count(*)
FROM feeds
JOIN entries ON (feeds.id = entries.feed_id)
WHERE feeds.category_id = c.id AND entries.status = 'unread') AS count_unread
WHERE feeds.category_id = c.id AND entries.status = $1) AS count_unread
FROM categories c
WHERE
user_id=$1
user_id=$2
`

if user.CategoriesSortingOrder == "alphabetical" {
Expand All @@ -145,7 +145,7 @@ func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error
`
}

rows, err := s.db.Query(query, userID)
rows, err := s.db.Query(query, model.EntryStatusUnread, userID)
if err != nil {
return nil, fmt.Errorf(`store: unable to fetch categories: %v`, err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/storage/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,12 @@ func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error)
UPDATE
entries
SET
status='removed'
status=$1
WHERE
id=ANY(SELECT id FROM entries WHERE status=$1 AND starred is false AND share_code='' AND created_at < now () - '%d days'::interval ORDER BY created_at ASC LIMIT %d)
id=ANY(SELECT id FROM entries WHERE status=$2 AND starred is false AND share_code='' AND created_at < now () - '%d days'::interval ORDER BY created_at ASC LIMIT %d)
`

result, err := s.db.Exec(fmt.Sprintf(query, days, limit), status)
result, err := s.db.Exec(fmt.Sprintf(query, days, limit), model.EntryStatusRemoved, status)
if err != nil {
return 0, fmt.Errorf(`store: unable to archive %s entries: %v`, status, err)
}
Expand Down
Loading