<commit_before>class MoveInappropriateFromVisibilityToVetted < ActiveRecord::Migration
  def self.up
    if inappropriate_visibility = Visibility.find_by_translated(:label, 'Inappropriate', 'en')
      inappropriate_visibility.translations.destroy_all
      
      inappropriate_vetted = Vetted.create(:view_order => 4)
      TranslatedVetted.create(:vetted => inappropriate_vetted, :label => 'Inappropriate',
        :language => Language.english)
      
      # Convert all the data objects of any vetted statuses and visibility status as inappropriate
      # to vetted status as inappropriate and visibility status as hidden
      execute("update data_objects set
        vetted_id = #{inappropriate_vetted.id},
        visibility_id = #{Visibility.invisible.id}
        where visibility_id = #{inappropriate_visibility.id}")
      inappropriate_visibility.destroy
    end
  end

  def self.down
    if inappropriate_vetted = Vetted.find_by_translated(:label, 'Inappropriate', 'en')
      inappropriate_vetted.translations.destroy_all
      
      inappropriate_visibility = Visibility.create()
      TranslatedVisibility.create(:visibility => inappropriate_visibility, :label => 'Inappropriate',
        :language => Language.english)
      
      # Data objects are irreversibile to their previous vetted statuses if they were trusted or unreviewed
      # but either way it doesn't make sense to have data objects with vetted and visibility statuses as 
      # (trusted and inappropriate) or (unreviewed and inappropriate) respectively.
      # So here I'm reverting them to (untrusted and inappropriate).
      execute("update data_objects set
        vetted_id = #{Vetted.untrusted.id},
        visibility_id = #{inappropriate_visibility.id}
        where vetted_id = #{inappropriate_vetted.id}")
      inappropriate_vetted.destroy
    end
  end
end<commit_msg>Modified the faulty migration added by me to update the visibility statuses in DOHE while moving inappropriate from visibility table to vetted table.<commit_after>class MoveInappropriateFromVisibilityToVetted < ActiveRecord::Migration
  def self.up
    if inappropriate_visibility = Visibility.find_by_translated(:label, 'Inappropriate', 'en')
      inappropriate_visibility.translations.destroy_all
      
      inappropriate_vetted = Vetted.create(:view_order => 4)
      TranslatedVetted.create(:vetted => inappropriate_vetted, :label => 'Inappropriate',
        :language => Language.english)
      
      # Convert all the data objects of any vetted statuses and visibility status as inappropriate
      # to vetted status as inappropriate and visibility status as hidden
      execute("update data_objects set
        vetted_id = #{inappropriate_vetted.id},
        visibility_id = #{Visibility.invisible.id}
        where visibility_id = #{inappropriate_visibility.id}")
      
      # Also update the records in the DOHE
      execute("update data_objects_hierarchy_entries set
        vetted_id = #{inappropriate_vetted.id},
        visibility_id = #{Visibility.invisible.id}
        where visibility_id = #{inappropriate_visibility.id}")
      
      inappropriate_visibility.destroy
    end
  end

  def self.down
    if inappropriate_vetted = Vetted.find_by_translated(:label, 'Inappropriate', 'en')
      inappropriate_vetted.translations.destroy_all
      
      inappropriate_visibility = Visibility.create()
      TranslatedVisibility.create(:visibility => inappropriate_visibility, :label => 'Inappropriate',
        :language => Language.english)
      
      # Data objects are irreversibile to their previous vetted statuses(so the DOHE) if they were trusted or 
      # unreviewed but either way it doesn't make sense to have data objects with vetted and visibility statuses 
      # as (trusted and inappropriate) or (unreviewed and inappropriate) respectively.
      # So here I'm reverting them to (untrusted and inappropriate).
      execute("update data_objects set
        vetted_id = #{Vetted.untrusted.id},
        visibility_id = #{inappropriate_visibility.id}
        where vetted_id = #{inappropriate_vetted.id}")
      inappropriate_vetted.destroy
      
      # Also update the records in the DOHE
      execute("update data_objects_hierarchy_entries set
        vetted_id = #{Vetted.untrusted.id},
        visibility_id = #{inappropriate_visibility.id}
        where vetted_id = #{inappropriate_vetted.id}")
    end
  end
end
{'fraction_non_alphanumeric': 0.0733468742947416, 'fraction_numerical': 0.0004513653802753329, 'mean_word_length': 3.5785123966942147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2655397', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1136, 'n_words': 329}