FIX: Cache all watched words (#14992)

It used to cache up to 1000 words, but the maximum number of watched
word is 2000.
This commit is contained in:
Bianca Nenciu 2021-11-17 18:59:44 +02:00 committed by GitHub
parent bf34d3524b
commit 186379adac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -8,7 +8,10 @@ class WordWatcher
end
def self.words_for_action(action)
words = WatchedWord.where(action: WatchedWord.actions[action.to_sym]).limit(1000)
words = WatchedWord
.where(action: WatchedWord.actions[action.to_sym])
.limit(WatchedWord::MAX_WORDS_PER_ACTION)
if WatchedWord.has_replacement?(action.to_sym)
words.pluck(:word, :replacement).to_h
else