{"action":"closed","issue":{"url":"https://api.github.com/repos/calacademy-research/antcat/issues/330","repository_url":"https://api.github.com/repos/calacademy-research/antcat","labels_url":"https://api.github.com/repos/calacademy-research/antcat/issues/330/labels{/name}","comments_url":"https://api.github.com/repos/calacademy-research/antcat/issues/330/comments","events_url":"https://api.github.com/repos/calacademy-research/antcat/issues/330/events","html_url":"https://github.com/calacademy-research/antcat/issues/330","id":267450207,"number":330,"title":"Delete unavailable uncategorized subspecies with names differing too much","user":{"login":"jonkerz","id":1513381,"avatar_url":"https://avatars3.githubusercontent.com/u/1513381?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkerz","html_url":"https://github.com/jonkerz","followers_url":"https://api.github.com/users/jonkerz/followers","following_url":"https://api.github.com/users/jonkerz/following{/other_user}","gists_url":"https://api.github.com/users/jonkerz/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkerz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkerz/subscriptions","organizations_url":"https://api.github.com/users/jonkerz/orgs","repos_url":"https://api.github.com/users/jonkerz/repos","events_url":"https://api.github.com/users/jonkerz/events{/privacy}","received_events_url":"https://api.github.com/users/jonkerz/received_events","type":"User","site_admin":false},"labels":[{"id":697107903,"url":"https://api.github.com/repos/calacademy-research/antcat/labels/script","name":"script","color":"FFA500","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-22T09:36:04Z","updated_at":"2017-10-22T10:28:51Z","closed_at":"2017-10-22T10:28:51Z","author_association":"MEMBER","body":"```ruby\r\n# \"Executed a script\" activity\r\njonkerz = User.find 60\r\nActivity.create! trackable: nil, action: :execute_script,\r\n  user: jonkerz, edit_summary: 'Delete unavailable uncategorized subspecies with names differing too much\"; see %github330.'\r\n\r\n# For PaperTrail\r\nantcat_bot = User.find 62\r\nPaperTrail.whodunnit = antcat_bot.id\r\n\r\n# Delete\r\nGENDER_ENDINGS = %w(\r\n  iarum\r\n  iorum\r\n  orum\r\n  arum\r\n  iae\r\n  ae\r\n  ii\r\n  i\r\n  er\r\n  era\r\n  ra\r\n  a\r\n  us\r\n  rum\r\n  um\r\n)\r\n\r\ndef gender_endings\r\n  @_gender_endings = GENDER_ENDINGS.join('|')\r\nend\r\n\r\ndef normalize_name name\r\n  name\r\n    .gsub(/(#{gender_endings})$/, '')\r\n    .gsub(/-/, '')\r\n    .downcase\r\nend\r\n\r\ndef too_different_ish_names? taxon\r\n  last_protonym = normalize_name taxon.protonym.name.name.split(' ').last\r\n  last_thing = normalize_name taxon.name.name.split(' ').last\r\n\r\n  last_protonym != last_thing\r\nend\r\n\r\nto_be_deleted = []\r\nSubspecies.where(status: \"unavailable uncategorized\").find_each do |taxon|\r\n  if taxon.species\r\n    to_be_deleted << taxon if too_different_ish_names?(taxon)\r\n  end\r\nend\r\n\r\nto_be_deleted.each(&:destroy); nil\r\n```"}}
{"actor":{"display_login":"jonkerz"}}