-
Notifications
You must be signed in to change notification settings - Fork 7
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
Script: Convert tax tags in 'synonym of' history items to prott tags #1183
Labels
Comments
Batch 1
BATCH = 1
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prott tags [batch #{BATCH}] (junior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_tax_or_taxac_tags.first)
new_taxt = old_taxt.sub(
/\{tax #{extracted_taxon.id}\}/,
"{prott #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Junior synonym of {tax [0-9]+}: {ref [0-9]+}: [0-9]+\.?$"); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
|
Batch 2
BATCH = 2
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prott tags [batch #{BATCH}] (senior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_tax_or_taxac_tags.first)
new_taxt = old_taxt.sub(
/\{tax #{extracted_taxon.id}\}/,
"{prott #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Senior synonym of {tax [0-9]+}: {ref [0-9]+}: [0-9]+\.?$"); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
|
Batch 3
BATCH = 3
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prott tags [batch #{BATCH}] (junior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_taxon_tags.first)
new_taxt = old_taxt.sub(
/\{tax #{extracted_taxon.id}\}/,
"{prott #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Junior synonym of {tax [0-9]+}: {ref [0-9]+}: "); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
|
Batch 4
BATCH = 4
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prott tags [batch #{BATCH}] (senior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_taxon_tags.first)
new_taxt = old_taxt.sub(
/\{tax #{extracted_taxon.id}\}/,
"{prott #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Senior synonym of {tax [0-9]+}: {ref [0-9]+}: "); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
|
Batch 5
BATCH = 5
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prottac tags [batch #{BATCH}] (junior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_taxon_tags.first)
new_taxt = old_taxt.sub(
/\{taxac #{extracted_taxon.id}\}/,
"{prottac #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Junior synonym of {taxac [0-9]+}: {ref [0-9]+}: "); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
Batch 6
BATCH = 6
EDIT_SUMMARY = "Convert tax tags in 'synonym of' history items to prottac tags [batch #{BATCH}] (senior synonym of), see %github1183"
ANTCATBOT = User.find_by!(name: 'AntCatBot')
# For activities and PaperTrail.
RequestStore.store[:current_request_uuid] = SecureRandom.uuid
PaperTrail.request.whodunnit = ANTCATBOT.id
def replace_with_prott_tag history_item
puts "ID: #{history_item.id}"
old_taxt = history_item.taxt.dup
extracted_taxon = Taxon.find(history_item.ids_from_taxon_tags.first)
new_taxt = old_taxt.sub(
/\{taxac #{extracted_taxon.id}\}/,
"{prottac #{extracted_taxon.protonym.id}}"
)
puts "old_taxt: #{old_taxt}".yellow
puts "new_taxt: #{new_taxt}".green
puts
history_item.update!(taxt: new_taxt)
history_item.create_activity :update, ANTCATBOT, edit_summary: EDIT_SUMMARY
end
items = HistoryItem.where('taxt REGEXP ?', "^Senior synonym of {taxac [0-9]+}: {ref [0-9]+}: "); nil
items.each do |item|
replace_with_prott_tag item
end; nil
Activity.execute_script_activity User.find_by!(name: 'Fredrik Palmkron'), EDIT_SUMMARY
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO:
These:
The text was updated successfully, but these errors were encountered: