limit number of synchronous saved search updates
This commit is contained in:
@@ -19,16 +19,18 @@ class SavedSearch < ApplicationRecord
|
|||||||
label = normalize_label(label) if label
|
label = normalize_label(label) if label
|
||||||
queries = queries_for(user_id, label: label)
|
queries = queries_for(user_id, label: label)
|
||||||
post_ids = Set.new
|
post_ids = Set.new
|
||||||
|
update_count = 0
|
||||||
queries.each do |query|
|
queries.each do |query|
|
||||||
redis_key = "search:#{query}"
|
redis_key = "search:#{query}"
|
||||||
if redis.exists(redis_key)
|
if redis.exists(redis_key)
|
||||||
sub_ids = redis.smembers(redis_key).map(&:to_i)
|
sub_ids = redis.smembers(redis_key).map(&:to_i)
|
||||||
post_ids.merge(sub_ids)
|
post_ids.merge(sub_ids)
|
||||||
redis.expire(redis_key, REDIS_EXPIRY)
|
redis.expire(redis_key, REDIS_EXPIRY)
|
||||||
elsif CurrentUser.is_gold?
|
elsif CurrentUser.is_gold? && update_count < 5
|
||||||
SavedSearch.populate(query)
|
SavedSearch.populate(query)
|
||||||
sub_ids = redis.smembers(redis_key).map(&:to_i)
|
sub_ids = redis.smembers(redis_key).map(&:to_i)
|
||||||
post_ids.merge(sub_ids)
|
post_ids.merge(sub_ids)
|
||||||
|
update_count += 1
|
||||||
else
|
else
|
||||||
SavedSearch.delay(queue: "default").populate(query)
|
SavedSearch.delay(queue: "default").populate(query)
|
||||||
end
|
end
|
||||||
|
|||||||
14
script/fixes/056_message_nonascii_usernames.rb
Normal file
14
script/fixes/056_message_nonascii_usernames.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||||
|
|
||||||
|
CurrentUser.user = User.system
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
|
User.where("name !~ ?", "^[ -~]*$").find_each do |user|
|
||||||
|
Dmail.create_automated(
|
||||||
|
:to_id => user.id,
|
||||||
|
:title => "Name change required",
|
||||||
|
:body => "Because of issues with users exploiting various Unicode characters in their name, in the future all non-ASCII characters and any non-printable characters will be forbidden. This means you will have to change your name. You can visit \"this page\":/user_name_change_requests/new to change your name. You will have 30 days to change your name or else your account will be banned."
|
||||||
|
)
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user