<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).


# GENERATE SUCCESS STORY Content
load './db/seeds/success_stories.rb'

# ******* NOTE ********
# You will have problems if you try to change the titles of courses/sections/lessons, since that's currently what's used to uniquely identify them!
# *********************

# The Structure:
# Course Has Many Sections. Section Belongs To Course.
# Section Has Many Lessons. Lesson Belongs To Section.

# with these values it prevents a course, section or lesson being assigned the same value, avoiding conflict
course_position = 0
section_position = 0
lesson_counter = 0

# number just throw all the positions into the stratosphere to avoid the annoyance of having to not duplicate them when updating lessons
incrementer = 1000

# Public: Only run this update attributes if all have one or more records in the database
if Course.all.any? && Section.all.any? && Lesson.all.any?
  Course.all.each { |c| c.update_attribute(:position, c.position + incrementer)}
  Section.all.each { |s| s.update_attribute(:position, s.position + incrementer)}
  Lesson.all.each { |l| l.update_attribute(:position, l.position + incrementer)}
end

def create_or_update_course(course_attrs)
  course = Course.where(title: course_attrs[:title]).first

  if course.nil?
    course = Course.create!(course_attrs)
    Rails.logger.info ">>>> Created new course: #{course_attrs[:title]}!"
  elsif course.attributes == course_attrs
    Rails.logger.info "No changes to existing course: #{course_attrs[:title]}"
  else
    course.update_attributes(course_attrs)
    Rails.logger.info "Updated existing << COURSE >>: #{course_attrs[:title]}"<commit_msg>remove incrementor code<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).


# GENERATE SUCCESS STORY Content
load './db/seeds/success_stories.rb'

# ******* NOTE ********
# You will have problems if you try to change the titles of courses/sections/lessons, since that's currently what's used to uniquely identify them!
# *********************

# The Structure:
# Course Has Many Sections. Section Belongs To Course.
# Section Has Many Lessons. Lesson Belongs To Section.

# with these values it prevents a course, section or lesson being assigned the same value, avoiding conflict
course_position = 0
section_position = 0
lesson_counter = 0

# number just throw all the positions into the stratosphere to avoid the annoyance of having to not duplicate them when updating lessons
incrementer = 1000

# Public: Only run this update attributes if all have one or more records in the database
# if Course.all.any? && Section.all.any? && Lesson.all.any?
#   Course.all.each { |c| c.update_attribute(:position, c.position + incrementer)}
#   Section.all.each { |s| s.update_attribute(:position, s.position + incrementer)}
#   Lesson.all.each { |l| l.update_attribute(:position, l.position + incrementer)}
# end

def create_or_update_course(course_attrs)
  course = Course.where(title: course_attrs[:title]).first

  if course.nil?
    course = Course.create!(course_attrs)
    Rails.logger.info ">>>> Created new course: #{course_attrs[:title]}!"
  elsif course.attributes == course_attrs
    Rails.logger.info "No changes to existing course: #{course_attrs[:title]}"
  else
    course.update_attributes(course_attrs)
    Rails.logger.info "Updated existing << COURSE >>: #{course_attrs[:title]}"
{'fraction_non_alphanumeric': 0.10981561822125814, 'fraction_numerical': 0.003796095444685466, 'mean_word_length': 4.818611987381703, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1293373', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1012, 'n_words': 393}