Don't compute reading-time when unused
If the user doesn't display reading times, there is no need to compute them. This should speed things up a bit, since `whatlanggo.Detect` is abysmally slow.
This commit is contained in:
parent
97765b93a9
commit
31ac62f410
2 changed files with 9 additions and 3 deletions
|
@ -275,7 +275,9 @@ func (h *handler) updateEntry(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
entryUpdateRequest.Patch(entry)
|
entryUpdateRequest.Patch(entry)
|
||||||
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
if user.ShowReadingTime {
|
||||||
|
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
||||||
|
}
|
||||||
|
|
||||||
if err := h.store.UpdateEntryTitleAndContent(entry); err != nil {
|
if err := h.store.UpdateEntryTitleAndContent(entry); err != nil {
|
||||||
json.ServerError(w, r, err)
|
json.ServerError(w, r, err)
|
||||||
|
|
|
@ -204,7 +204,9 @@ func ProcessEntryWebPage(feed *model.Feed, entry *model.Entry, user *model.User)
|
||||||
|
|
||||||
if content != "" {
|
if content != "" {
|
||||||
entry.Content = content
|
entry.Content = content
|
||||||
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
if user.ShowReadingTime {
|
||||||
|
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rewrite.Rewriter(websiteURL, entry, entry.Feed.RewriteRules)
|
rewrite.Rewriter(websiteURL, entry, entry.Feed.RewriteRules)
|
||||||
|
@ -282,7 +284,9 @@ func updateEntryReadingTime(store *storage.Storage, feed *model.Feed, entry *mod
|
||||||
}
|
}
|
||||||
// Handle YT error case and non-YT entries.
|
// Handle YT error case and non-YT entries.
|
||||||
if entry.ReadingTime == 0 {
|
if entry.ReadingTime == 0 {
|
||||||
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
if user.ShowReadingTime {
|
||||||
|
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue