1
0
Fork 0

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

This commit is contained in:
Frédéric Guillot 2019-02-28 20:43:33 -08:00
parent 1634e267b8
commit f3fc8b7072
2 changed files with 4 additions and 4 deletions

View file

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

View file

@ -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. // 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 var result int
query := `SELECT count(*) as c FROM entries WHERE user_id=$1 AND url=$2` query := `SELECT count(*) as c FROM entries WHERE feed_id=$1 AND url=$2`
s.db.QueryRow(query, userID, entryURL).Scan(&result) s.db.QueryRow(query, feedID, entryURL).Scan(&result)
return result >= 1 return result >= 1
} }