האם ניתן לתמוך במחיקה קבוצתית של סמלי הבעה מותאמים אישית?

אם יש הרבה סמלים רגשיים, מחיקתם אחד אחד היא משימה גדולה.

You can look at Administrative Bulk Operations.

Something like this would work

remove=Post.where("raw like '%:some_emoji%'")
remove.each do |post|
  new_raw=post.raw.gsub(":some_emoji","")
  if new_raw != post.raw
            PostRevisor.new(post).revise!(
              post.user,
              { raw: new_raw },
              bypass_bump: true,
              edit_reason: "Remove emoji we no longer like",
              bypass_rate_limiter: true,
            )
  end
end

You should test it, but it does create edits so you can undo it.

If you don’t want edits you could instead of PostRevisor do post.raw=new_raw;post.save.

6 לייקים

תודה! זה מאוד מועיל

לייק 1

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.