We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
missing
For #35
BATCH = 1 EDIT_SUMMARY = "Replace `missing` tags with other `missing` tags [batch #{BATCH}], see %github1074" ANTCATBOT = User.find_by!(name: 'AntCatBot') # For activities and PaperTrail. RequestStore.store[:current_request_uuid] = SecureRandom.uuid PaperTrail.request.whodunnit = ANTCATBOT.id MAX_REPLACE_IN_BATCH = 9999 $replaced_in_batch = 0 def replace_with_other_missing_tags! to_replace, replace_with escaped_to_replace = to_replace.dup escaped_to_replace = escaped_to_replace.gsub!('(', '\\(') escaped_to_replace = escaped_to_replace.gsub!(')', '\\)') items = TaxonHistoryItem.where("taxt REGEXP ?", escaped_to_replace) puts "#{to_replace}: #{items.count}" items.find_each do |item| old_taxt = item.taxt.dup new_taxt = item.taxt.dup new_taxt.gsub!(to_replace, replace_with) if old_taxt == new_taxt puts "nothing was changed: #{item.id} - #{to_replace}".red return end item.update!(taxt: new_taxt) item.create_activity :update, ANTCATBOT, edit_summary: "Replace `#{to_replace}` with `#{replace_with}` [batch #{BATCH}], see %github1074" puts "OK".green $replaced_in_batch += 1 end end # --- replacements = [ ["{missing Neivamyrmex (Acamatus)}", "{missing Eciton (Acamatus)}"], ["{missing Neivamyrmex (Neivamyrmex)}", "{missing Eciton (Neivamyrmex)}"], ["{missing Temnothorax (Myrafant)}", "{missing Leptothorax (Myrafant)}"], ["{missing Hypoponera (Hypoponera)}", "{missing Ponera (Hypoponera)}"], ["{missing Nesomyrmex (Goniothorax)}", "{missing Leptothorax (Goniothorax)}"], ["{missing Nesomyrmex (Nesomyrmex)}", "{missing Leptothorax (Nesomyrmex)}"] ] replacements.each do |(to_replace, replace_with)| if $replaced_in_batch > MAX_REPLACE_IN_BATCH break end replace_with_other_missing_tags! to_replace, replace_with end; nil # --- Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
The text was updated successfully, but these errors were encountered:
BATCH = 2 EDIT_SUMMARY = "Replace `missing` tags with other `missing` tags [batch #{BATCH}], see %github1074" ANTCATBOT = User.find_by!(name: 'AntCatBot') # For activities and PaperTrail. RequestStore.store[:current_request_uuid] = SecureRandom.uuid PaperTrail.request.whodunnit = ANTCATBOT.id MAX_REPLACE_IN_BATCH = 9999 $replaced_in_batch = 0 def replace_with_other_missing_tags! to_replace, replace_with escaped_to_replace = to_replace.dup escaped_to_replace = escaped_to_replace.gsub!('(', '\\(') escaped_to_replace = escaped_to_replace.gsub!(')', '\\)') items = TaxonHistoryItem.where("taxt REGEXP ?", escaped_to_replace) puts "#{to_replace}: #{items.count}" items.find_each do |item| old_taxt = item.taxt.dup new_taxt = item.taxt.dup new_taxt.gsub!(to_replace, replace_with) if old_taxt == new_taxt puts "nothing was changed: #{item.id} - #{to_replace}".red return end item.update!(taxt: new_taxt) item.create_activity :update, ANTCATBOT, edit_summary: "Replace `#{to_replace}` with `#{replace_with}` [batch #{BATCH}], see %github1074" puts "OK".green $replaced_in_batch += 1 end end # --- replacements = [ ["{missing <i>Neivamyrmex (Acamatus)</i>}", "{missing Eciton (Acamatus)}"], ["{missing <i>Neivamyrmex (Labidus)</i>}", "{missing Eciton (Labidus)}"], ["{missing Neivamyrmex (Labidus)}", "{missing Eciton (Labidus)}"], ["{missing Rhytidoponera (Rhytidoponera)}", "{missing Ectatomma (Rhytidoponera)}"], ["{missing Temnothorax (Temnothorax)}", "{missing Leptothorax (Temnothorax)}"], ["{missing Paraparatrechina (Nylanderia)}", "{missing Prenolepis (Nylanderia)}"] ] replacements.each do |(to_replace, replace_with)| if $replaced_in_batch > MAX_REPLACE_IN_BATCH break end replace_with_other_missing_tags! to_replace, replace_with end; nil # --- Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
Sorry, something went wrong.
No branches or pull requests
For #35
The text was updated successfully, but these errors were encountered: