diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c5fa0e04f..341db5187 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -602,7 +602,9 @@ def save_draft key_name = [:body, :saved_at].include?(key) ? base_key : "#{base_key}.#{key}" if key == :tags - RequestContext.redis.sadd(key_name, params[key]) + if params[key].present? + RequestContext.redis.sadd(key_name, params[key]) + end else RequestContext.redis.set(key_name, params[key]) end diff --git a/config/schedule.rb b/config/schedule.rb index 03648b0ee..39d5eee0b 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -14,6 +14,10 @@ runner 'scripts/run_spam_cleanup.rb' end +every 1.day, at: '02:20' do + runner 'scripts/cleanup_drafts.rb' +end + every 6.hours do runner 'scripts/recalc_abilities.rb' end diff --git a/scripts/cleanup_drafts.rb b/scripts/cleanup_drafts.rb new file mode 100644 index 000000000..27ef4eb63 --- /dev/null +++ b/scripts/cleanup_drafts.rb @@ -0,0 +1,5 @@ +redis = RequestContext.redis + +redis.scan_each(:match => "saved_post.*.*.tags") do |key| + redis.srem?(key, '') +end \ No newline at end of file