<commit_before>class CourseCloneManager

  def initialize(course, user)
    @course = course
    @user = user
  end

  def clone!
    @clone = @course.deep_clone include: [ { weeks:  { blocks: :gradeable } } ]
    sanitize_clone_info
    update_title_and_slug
    clear_dates
    set_instructor
    return @clone
  end

  private

  def sanitize_clone_info
    @clone.title = "#{@course.title} (Copy)"
    set_slug(@clone)
    @clone.passcode = Course.generate_passcode
    @clone.submitted = false
    @clone.save
    @clone.update_cache
  end

  def update_title_and_slug
    new_course = Course.last
    new_course.update_attributes(
      title: @clone.title,
      slug: @clone.slug
    )
  end

  def clear_dates
    @clone.update_attributes(meeting_days: nil, day_exceptions: nil, weekdays: '0000000', no_day_exceptions: nil)
    @clone.blocks.update_all(due_date: nil)
  end

  def set_instructor
    CoursesUsers.create!(course_id: @clone.id, user_id: @user.id, role: 1)
  end

  def set_slug(course)
    course.slug = "#{course.school}/#{course.title}_(#{course.term}__COPY__)".gsub(' ', '_')
  end
end
<commit_msg>don't append (Copy) to course's name<commit_after>class CourseCloneManager

  def initialize(course, user)
    @course = course
    @user = user
  end

  def clone!
    @clone = @course.deep_clone include: [ { weeks:  { blocks: :gradeable } } ]
    sanitize_clone_info
    update_title_and_slug
    clear_dates
    set_instructor
    return @clone
  end

  private

  def sanitize_clone_info
    set_slug(@clone)
    @clone.passcode = Course.generate_passcode
    @clone.submitted = false
    @clone.save
    @clone.update_cache
  end

  def update_title_and_slug
    new_course = Course.last
    new_course.update_attributes(
      title: @clone.title,
      slug: @clone.slug
    )
  end

  def clear_dates
    @clone.update_attributes(meeting_days: nil, day_exceptions: nil, weekdays: '0000000', no_day_exceptions: nil)
    @clone.blocks.update_all(due_date: nil)
  end

  def set_instructor
    CoursesUsers.create!(course_id: @clone.id, user_id: @user.id, role: 1)
  end

  def set_slug(course)
    course.slug = "#{course.school}/#{course.title}_(#{course.term}__COPY__)".gsub(' ', '_')
  end
end

{'fraction_non_alphanumeric': 0.10861759425493717, 'fraction_numerical': 0.00718132854578097, 'mean_word_length': 3.4402390438247012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2822518', 'n_tokens_mistral': 799, 'n_tokens_neox': 782, 'n_words': 156}