mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Add bookmarks
This commit is contained in:
parent
b153fa8b3c
commit
9868f900e9
31 changed files with 688 additions and 78 deletions
|
@ -179,11 +179,24 @@ func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string
|
|||
return nil
|
||||
}
|
||||
|
||||
// ToggleBookmark toggles entry bookmark value.
|
||||
func (s *Storage) ToggleBookmark(userID int64, entryID int64) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:ToggleBookmark] userID=%d, entryID=%d", userID, entryID))
|
||||
|
||||
query := `UPDATE entries SET starred = NOT starred WHERE user_id=$1 AND id=$2`
|
||||
_, err := s.db.Exec(query, userID, entryID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to update toggle bookmark: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FlushHistory set all entries with the status "read" to "removed".
|
||||
func (s *Storage) FlushHistory(userID int64) error {
|
||||
defer helper.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:FlushHistory] userID=%d", userID))
|
||||
|
||||
query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3`
|
||||
query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3 AND starred='f'`
|
||||
_, err := s.db.Exec(query, model.EntryStatusRemoved, userID, model.EntryStatusRead)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to flush history: %v", err)
|
||||
|
|
|
@ -32,6 +32,13 @@ type EntryQueryBuilder struct {
|
|||
greaterThanEntryID int64
|
||||
entryIDs []int64
|
||||
before *time.Time
|
||||
starred bool
|
||||
}
|
||||
|
||||
// WithStarred adds starred filter.
|
||||
func (e *EntryQueryBuilder) WithStarred() *EntryQueryBuilder {
|
||||
e.starred = true
|
||||
return e
|
||||
}
|
||||
|
||||
// Before add condition base on the entry date.
|
||||
|
@ -150,7 +157,8 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
|
|||
|
||||
query := `
|
||||
SELECT
|
||||
e.id, e.user_id, e.feed_id, e.hash, e.published_at at time zone '%s', e.title, e.url, e.author, e.content, e.status,
|
||||
e.id, e.user_id, e.feed_id, e.hash, e.published_at at time zone '%s', e.title,
|
||||
e.url, e.author, e.content, e.status, e.starred,
|
||||
f.title as feed_title, f.feed_url, f.site_url, f.checked_at,
|
||||
f.category_id, c.title as category_title, f.scraper_rules, f.rewrite_rules, f.crawler,
|
||||
fi.icon_id
|
||||
|
@ -191,6 +199,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
|
|||
&entry.Author,
|
||||
&entry.Content,
|
||||
&entry.Status,
|
||||
&entry.Starred,
|
||||
&entry.Feed.Title,
|
||||
&entry.Feed.FeedURL,
|
||||
&entry.Feed.SiteURL,
|
||||
|
@ -303,6 +312,10 @@ func (e *EntryQueryBuilder) buildCondition() ([]interface{}, string) {
|
|||
args = append(args, e.before)
|
||||
}
|
||||
|
||||
if e.starred {
|
||||
conditions = append(conditions, "e.starred is true")
|
||||
}
|
||||
|
||||
return args, strings.Join(conditions, " AND ")
|
||||
}
|
||||
|
||||
|
@ -334,5 +347,6 @@ func NewEntryQueryBuilder(store *Storage, userID int64, timezone string) *EntryQ
|
|||
store: store,
|
||||
userID: userID,
|
||||
timezone: timezone,
|
||||
starred: false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/miniflux/miniflux/sql"
|
||||
)
|
||||
|
||||
const schemaVersion = 11
|
||||
const schemaVersion = 12
|
||||
|
||||
// Migrate run database migrations.
|
||||
func (s *Storage) Migrate() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue