<commit_before>namespace :db do
  namespace :setup do
    # Contact
    desc "Ensures every Institution has an contact object"
    task :contacts => :environment do
      Institution.all.each do |i|
        if i.contact.nil?
          i.contact = Contact.create(institution_id: i.id)
          if i.save
            puts "--> OK: Created CONTACT for INSTITUTION: #{i.id} - #{i.name}"
          else
            puts "FAILED: Failed to create missing CONTACT for INSTITUTION: #{i.id} - #{i.name}"
          end
        elsif i.contact.instance_of? Contact::ActiveRecord_Relation
          puts "WARNING: More than one CONTACT record for INSTITUTION: #{i.id} - #{i.name}"
        end
      end
    end

    # Filters
    desc "Ensures every Institution has a filters object"
    task :filters => :environment do
      Institution.all.each do |i|
        if i.filter.nil?
          i.filter = Filter.create(institution_id: i.id)
          if i.save
            puts "--> OK: Created FILTERS for INSTITUTION: #{i.id} - #{i.name}"
          else
            puts "FAILED: Failed to create missing FILTERS for INSTITUTION: #{i.id} - #{i.name}"
          end
        elsif i.filter.length > 1
          puts "WARNING: More than one FILTERS record for INSTITUTION: #{i.id} - #{i.name}"
        end
      end
    end

    # Hours
    desc "Ensures every Institution has an hours object"<commit_msg>Fixing db:setup:filters<commit_after>namespace :db do
  namespace :setup do
    # Contact
    desc "Ensures every Institution has an contact object"
    task :contacts => :environment do
      Institution.all.each do |i|
        if i.contact.nil?
          i.contact = Contact.create(institution_id: i.id)
          if i.save
            puts "--> OK: Created CONTACT for INSTITUTION: #{i.id} - #{i.name}"
          else
            puts "FAILED: Failed to create missing CONTACT for INSTITUTION: #{i.id} - #{i.name}"
          end
        elsif i.contact.instance_of? Contact::ActiveRecord_Relation
          puts "WARNING: More than one CONTACT record for INSTITUTION: #{i.id} - #{i.name}"
        end
      end
    end

    # Filters
    desc "Ensures every Institution has a filters object"
    task :filters => :environment do
      Institution.all.each do |i|
        if i.filter.nil?
          i.filter = Filter.create(institution_id: i.id)
          if i.save
            puts "--> OK: Created FILTERS for INSTITUTION: #{i.id} - #{i.name}"
          else
            puts "FAILED: Failed to create missing FILTERS for INSTITUTION: #{i.id} - #{i.name}"
          end
        else
          puts "--> OK: Filter exists for INSTITUTION: #{i.id} - #{i.name}"
        end
      end
    end

    # Hours
    desc "Ensures every Institution has an hours object"
{'fraction_non_alphanumeric': 0.1054162122864413, 'fraction_numerical': 0.0003635041802980734, 'mean_word_length': 2.014238773274918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5250961', 'n_tokens_mistral': 869, 'n_tokens_neox': 838, 'n_words': 269}