8000 [pull] main from miniflux:main by pull[bot] · Pull Request #273 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
8000
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/andybalholm/brotli v1.2.1
github.com/coreos/go-oidc/v3 v3.17.0
github.com/go-webauthn/webauthn v0.16.2
github.com/lib/pq v1.12.2
github.com/lib/pq v1.12.3
github.com/prometheus/client_golang v1.23.2
github.com/tdewolff/minify/v2 v2.24.11
golang.org/x/crypto v0.49.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.12.2 h1:ajJNv84limnK3aPbDIhLtcjrUbqAw/5XNdkuI6KNe/Q=
github.com/lib/pq v1.12.2/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ=
github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
Expand Down
14 changes: 7 additions & 7 deletions internal/storage/entry.go
8000
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ func (s *Storage) getEntryIDByHash(tx *sql.Tx, feedID int64, entryHash string) (
entryHash,
).Scan(&entryID)

if err == sql.ErrNoRows {
return 0, nil
}
if err != nil {
return 0, fmt.Errorf(`store: unable to fetch entry ID: %v`, err)
}
Expand All @@ -264,16 +267,13 @@ func (s *Storage) InsertEntryForFeed(userID, feedID int64, entry *model.Entry) (
}
defer tx.Rollback()

exists, err := s.entryExists(tx, entry)
entryID, err := s.getEntryIDByHash(tx, entry.FeedID, entry.Hash)
if err != nil {
return false, err
}
alreadyExistingEntry := entryID > 0

if exists {
entryID, err := s.getEntryIDByHash(tx, entry.FeedID, entry.Hash)
if err != nil {
return false, err
}
if alreadyExistingEntry {
entry.ID = entryID
} else {
if err := s.createEntry(tx, entry); err != nil {
Expand All @@ -285,7 +285,7 @@ func (s *Storage) InsertEntryForFeed(userID, feedID int64, entry *model.Entry) (
return false, err
}

return !exists, nil
return !alreadyExistingEntry, nil
}

func (s *Storage) IsNewEntry(feedID int64, entryHash string) bool {
Expand Down
14 changes: 11 additions & 3 deletions internal/storage/entry_query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ func (e *EntryQueryBuilder) AfterEntryID(entryID int64) *EntryQueryBuilder {

// WithEntryIDs filter by entry IDs.
func (e *EntryQueryB 9264 uilder) WithEntryIDs(entryIDs []int64) *EntryQueryBuilder {
e.conditions = append(e.conditions, fmt.Sprintf("e.id = ANY($%d)", len(e.args)+1))
e.args = append(e.args, pq.Int64Array(entryIDs))
if len(entryIDs) == 1 {
e.conditions = append(e.conditions, fmt.Sprintf("e.id = $%d", len(e.args)+1))
e.args = append(e.args, entryIDs[0])
} else if len(entryIDs) > 1 {
e.conditions = append(e.conditions, fmt.Sprintf("e.id = ANY($%d)", len(e.args)+1))
e.args = append(e.args, pq.Int64Array(entryIDs))
}
return e
}

Expand Down Expand Up @@ -150,7 +155,10 @@ func (e *EntryQueryBuilder) WithStatus(status string) *EntryQueryBuilder {

// WithStatuses filter by a list of entry statuses.
func (e *EntryQueryBuilder) WithStatuses(statuses []string) *EntryQueryBuilder {
if len(statuses) > 0 {
if len(statuses) == 1 {
e.conditions = append(e.conditions, fmt.Sprintf("e.status = $%d", len(e.args)+1))
e.args = append(e.args, statuses[0])
} else if len(statuses) > 1 {
e.conditions = append(e.conditions, fmt.Sprintf("e.status = ANY($%d)", len(e.args)+1))
e.args = append(e.args, pq.StringArray(statuses))
}
Expand Down
Loading
0