From 38b80d96eaa4aa57a95d02ae4ffd1d5833c7c7e7 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 4 Apr 2024 21:19:02 -0700 Subject: storage: change GetReadTime() function to use entries_feed_id_hash_key index --- internal/reader/processor/processor.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'internal/reader/processor/processor.go') diff --git a/internal/reader/processor/processor.go b/internal/reader/processor/processor.go index ab4448ef..eb2e2f9d 100644 --- a/internal/reader/processor/processor.go +++ b/internal/reader/processor/processor.go @@ -251,6 +251,11 @@ func getUrlFromEntry(feed *model.Feed, entry *model.Entry) string { } func updateEntryReadingTime(store *storage.Storage, feed *model.Feed, entry *model.Entry, entryIsNew bool, user *model.User) { + if !user.ShowReadingTime { + slog.Debug("Skip reading time estimation for this user", slog.Int64("user_id", user.ID)) + return + } + if shouldFetchYouTubeWatchTime(entry) { if entryIsNew { watchTime, err := fetchYouTubeWatchTime(entry.URL) @@ -266,7 +271,7 @@ func updateEntryReadingTime(store *storage.Storage, feed *model.Feed, entry *mod } entry.ReadingTime = watchTime } else { - entry.ReadingTime = store.GetReadTime(entry, feed) + entry.ReadingTime = store.GetReadTime(feed.ID, entry.Hash) } } @@ -285,14 +290,13 @@ func updateEntryReadingTime(store *storage.Storage, feed *model.Feed, entry *mod } entry.ReadingTime = watchTime } else { - entry.ReadingTime = store.GetReadTime(entry, feed) + entry.ReadingTime = store.GetReadTime(feed.ID, entry.Hash) } } + // Handle YT error case and non-YT entries. if entry.ReadingTime == 0 { - if user.ShowReadingTime { - entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed) - } + entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed) } } -- cgit v1.2.3