<commit_before># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).

# Clear stuff
if Rails.env.development? or Rails.env.test?
  $redis.FLUSHDB                # Clear the Redis DB
  User.all.delete
  Site.all.delete               # Self explainatory
  Basefact.all.delete
  Fact.all.delete           # Self explainatory
  Factlink.all.delete
  Sunspot.remove_all!(Fact) # Remove the indices of all Facts in Solr.
end

# A user
user = User.new(:username => "robin",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user.save

user1 = User.new(:username => "tomdev",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user1.save


# Opinionators
user2 = User.new(:username => "michael_night",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user2.save

user3 = User.new(:username => "kate_upton",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user3.save

user3 = User.new(:username => "george_lucas",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user3.save

user4 = User.new(:username => "will_smith",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user4.save

user5 = User.new(:username => "snookie",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user5.save


# Site
site = Site.new(:url => "http://en.wikipedia.org/wiki/Batman")
site.save

facts = [
'Batman is a fictional character created by the artist <NAME> and writer <NAME>',
'Batman\'s secret identity is <NAME>',
'Batman operates in the fictional American Gotham City',
'He fights an assortment of villains such as the Joker, the Penguin, Two-Face, Poison Ivy and Catwoman',
'The late 1960s Batman television series used a camp aesthetic which continued to be associated with the character for years after the show ended']

facts.each do |fact|
  Fact.create!( :displaystring => fact,
                    :site => site,
                    :created_by => user
  )
end

# parent  = Fact.all[0]
# child   = Fact.all[1]

# parent.add_evidence(:supporting, child, user)

# fl = Factlink.find(parent.evidence(:supporting).members[0])
# fl.add_opinion(:beliefs, user)
# fl.add_opinion(:beliefs, user1)
# fl.add_opinion(:beliefs, user2)
# 
# fl.add_opinion(:doubts, user3)
# 
# fl.add_opinion(:disbeliefs, user4)
# fl.add_opinion(:disbeliefs, user5)

# Commit the indices to Solr
Sunspot.commit<commit_msg>added a factlink to the seed<commit_after># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).

# Clear stuff
if Rails.env.development? or Rails.env.test?
  $redis.FLUSHDB                # Clear the Redis DB
  User.all.delete
  Site.all.delete               # Self explainatory
  Basefact.all.delete
  Fact.all.delete           # Self explainatory
  Factlink.all.delete
  Sunspot.remove_all!(Fact) # Remove the indices of all Facts in Solr.
end

# A user
user = User.new(:username => "robin",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user.save

user1 = User.new(:username => "tomdev",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user1.save


# Opinionators
user2 = User.new(:username => "michael_night",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user2.save

user3 = User.new(:username => "kate_upton",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user3.save

user3 = User.new(:username => "george_lucas",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user3.save

user4 = User.new(:username => "will_smith",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user4.save

user5 = User.new(:username => "snookie",
                :email => "<EMAIL>",
                :confirmed_at => DateTime.now,
                :password => "<PASSWORD>",
                :password_confirmation => "<PASSWORD>")
user5.save


# Site
site = Site.new(:url => "http://en.wikipedia.org/wiki/Batman")
site.save

facts = [
'Batman is a fictional character created by the artist <NAME> and writer <NAME>',
'Batman\'s secret identity is <NAME>',
'Batman operates in the fictional American Gotham City',
'He fights an assortment of villains such as the Joker, the Penguin, Two-Face, Poison Ivy and Catwoman',
'The late 1960s Batman television series used a camp aesthetic which continued to be associated with the character for years after the show ended']

facts.each do |fact|
  Fact.create!( :displaystring => fact,
                    :site => site,
                    :created_by => user
  )
end

Factlink.get_or_create(Fact.first,:supports, Fact.last, User.first)

# parent  = Fact.all[0]
# child   = Fact.all[1]

# parent.add_evidence(:supporting, child, user)

# fl = Factlink.find(parent.evidence(:supporting).members[0])
# fl.add_opinion(:beliefs, user)
# fl.add_opinion(:beliefs, user1)
# fl.add_opinion(:beliefs, user2)
# 
# fl.add_opinion(:doubts, user3)
# 
# fl.add_opinion(:disbeliefs, user4)
# fl.add_opinion(:disbeliefs, user5)

# Commit the indices to Solr
Sunspot.commit
{'fraction_non_alphanumeric': 0.13335295849278775, 'fraction_numerical': 0.007065057403591404, 'mean_word_length': 2.481045081967213, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 129, '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': '571681', 'n_tokens_mistral': 2103, 'n_tokens_neox': 1945, 'n_words': 533}