Browse Source

Use feed ID instead of user ID to check entry URLs presence

Frédéric Guillot 7 months ago
parent
commit
f3fc8b7072
2 changed files with 4 additions and 4 deletions
  1. 1 1
      reader/processor/processor.go
  2. 3 3
      storage/entry.go

+ 1 - 1
reader/processor/processor.go

@@ -17,7 +17,7 @@ import (
 func ProcessFeedEntries(store *storage.Storage, feed *model.Feed) {
 	for _, entry := range feed.Entries {
 		if feed.Crawler {
-			if !store.EntryURLExists(feed.UserID, entry.URL) {
+			if !store.EntryURLExists(feed.ID, entry.URL) {
 				content, err := scraper.Fetch(entry.URL, feed.ScraperRules, feed.UserAgent)
 				if err != nil {
 					logger.Error(`[Filter] Unable to crawl this entry: %q => %v`, entry.URL, err)

+ 3 - 3
storage/entry.go

@@ -316,9 +316,9 @@ func (s *Storage) MarkCategoryAsRead(userID, categoryID int64, before time.Time)
 }
 
 // EntryURLExists returns true if an entry with this URL already exists.
-func (s *Storage) EntryURLExists(userID int64, entryURL string) bool {
+func (s *Storage) EntryURLExists(feedID int64, entryURL string) bool {
 	var result int
-	query := `SELECT count(*) as c FROM entries WHERE user_id=$1 AND url=$2`
-	s.db.QueryRow(query, userID, entryURL).Scan(&result)
+	query := `SELECT count(*) as c FROM entries WHERE feed_id=$1 AND url=$2`
+	s.db.QueryRow(query, feedID, entryURL).Scan(&result)
 	return result >= 1
 }