<commit_before>require 'imdb'
require 'awesome_print'
require 'httparty'


query = Imdb::Top250.new
query.movies.each do |m|
  response = HTTParty.get("http://www.omdbapi.com/?i=tt#{m.id}&plot=short&r=json")
    unless Movie.exists?(title: response['Title'])
      Movie.create!(title: response['Title'], synopsis: response['Plot'], release_date: response['Released'], movie_poster_url: response['Poster']  )
    end
    actors_list = response['Actors'].split(', ')
    actors_list.each do |a|
      unless Actor.exists?(name: a)
        Actor.create!(name: a)
      end
        Role.create!(actor: Actor.find_by(name: a), movie: Movie.find_by(title: response['Title']))
    end
end

5.times do
  User.create!(username: Faker::StarWars.character,
                 email: Faker::Internet.free_email,
              password: "password"
              )
end

10.times do
  Review.create!(title: Faker::Book.title,
              content: Faker::Hipster.paragraph,
              upvotes: rand(1..9),
              downvotes: rand(1..9),
              rating: rand(1..5),
              reviewer_id: rand(1..5),
              reviewable_id: rand(1..10),
              reviewable_type: ['Actor', 'Movie'].sample
              )
end

10.times do
  Comment.create!(content: Faker::Hacker.say_something_smart,
             commenter_id: rand(1..5),
                review_id: rand(1..10)
                )
end<commit_msg>fix issue with double-adding roles (due to the data having each movie twice) and standardize formatting<commit_after>require 'imdb'
require 'awesome_print'
require 'httparty'


query = Imdb::Top250.new
query.movies.each do |m|
  response = HTTParty.get("http://www.omdbapi.com/?i=tt#{m.id}&plot=short&r=json")
  next if Movie.exists?(title: response['Title'])
  Movie.create!(title: response['Title'],
             synopsis: response['Plot'],
         release_date: response['Released'],
     movie_poster_url: response['Poster']
  )
  actors_list = response['Actors'].split(', ')
  actors_list.each do |a|
    Actor.create!(name: a) unless Actor.exists?(name: a)
    Role.create!(actor: Actor.find_by(name: a),
                 movie: Movie.find_by(title: response['Title'])
    )
  end
end

5.times do
  User.create!(username: Faker::StarWars.character,
                  email: Faker::Internet.free_email,
               password: "password"
  )
end

10.times do
  Review.create!( title: Faker::Book.title,
                  content: Faker::Hipster.paragraph,
                  upvotes: rand(1..9),
                  downvotes: rand(1..9),
                  rating: rand(1..5),
                  reviewer_id: rand(1..5),
                  reviewable_id: rand(1..10),
                  reviewable_type: ['Actor', 'Movie'].sample
  )
end

10.times do
  Comment.create!(content: Faker::Hacker.say_something_smart,
             commenter_id: rand(1..5),
                review_id: rand(1..10)
  )
end
{'fraction_non_alphanumeric': 0.14614855570839064, 'fraction_numerical': 0.016506189821182942, 'mean_word_length': 2.5006016847172083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3651000', 'n_tokens_mistral': 962, 'n_tokens_neox': 925, 'n_words': 178}