Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty ephemeral tags in post drafts if the draft is saved with no tags #1458

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions scripts/cleanup_drafts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
redis = RequestContext.redis

redis.scan_each(:match => "saved_post.*.*.tags") do |key|
redis.srem?(key, '')
end
Loading