<commit_before>class FluxxGrantAddHierarchyMarkerToExistingDashboards < ActiveRecord::Migration
  def self.up
    # Switch dashboards from the old format to the new format for request hierarchy
    ClientStore.all.each do |client_store|
      if client_store.data
        funj = client_store.data.de_json
        funj['cards'].each do |card|
          if data_attrs = card['listing']['data']
            if data_attrs.any?{|element| element.to_json =~ /"name":"request/}
              data_attrs << {"name" => "request[hierarchies][]", "value" => "request_hierarchy"}
              data_attrs << {"name" => "request[hierarchies][]", "value" => "allocation_hierarchy"}
            end
          end
        end
        client_store.data = funj.to_json
        client_store.save
      end
    end
  end

  def self.down
    
  end
end<commit_msg>make it so that we convert the request transaction and request report dashboards as well<commit_after>class FluxxGrantAddHierarchyMarkerToExistingDashboards < ActiveRecord::Migration
  def self.up
    # Switch dashboards from the old format to the new format for request hierarchy
    ClientStore.all.each do |client_store|
      if client_store.data
        funj = client_store.data.de_json
        funj['cards'].each do |card|
          if data_attrs = card['listing']['data']
            if data_attrs.any?{|element| element.to_json =~ /"name":"request\[/}
              data_attrs << {"name" => "request[hierarchies][]", "value" => "request_hierarchy"}
              data_attrs << {"name" => "request[hierarchies][]", "value" => "allocation_hierarchy"}
            end
            if data_attrs.any?{|element| element.to_json =~ /"name":"request_transaction\[/}
              data_attrs << {"name" => "request_transaction[hierarchies][]", "value" => "request_hierarchy"}
              data_attrs << {"name" => "request_transaction[hierarchies][]", "value" => "allocation_hierarchy"}
            end
            if data_attrs.any?{|element| element.to_json =~ /"name":"request_report\[/}
              data_attrs << {"name" => "request_report[hierarchies][]", "value" => "request_hierarchy"}
              data_attrs << {"name" => "request_report[hierarchies][]", "value" => "allocation_hierarchy"}
            end
          end
        end
        client_store.data = funj.to_json
        client_store.save
      end
    end
  end

  def self.down
    
  end
end
{'fraction_non_alphanumeric': 0.12780082987551866, 'fraction_numerical': 0.0, 'mean_word_length': 2.7554517133956384, 'pattern_counts': {'":': 4, '<': 21, '<?xml version=': 0, '>': 19, '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': '3406912', 'n_tokens_mistral': 733, 'n_tokens_neox': 724, 'n_words': 159}