<commit_before>def transform_lesson_plans(course_ids = [])
  transform_table :lesson_plan_milestones,
                  to: ::Course::LessonPlan::Milestone,
                  default_scope: proc { within_courses(course_ids) } do
    primary_key :id
    column to: :course_id do
      V1::Source::Course.transform(source_record.course_id)
    end
    column :title
    column :description
    column :start_at
    column to: :creator_id do
      result = V1::Source::User.transform(source_record.creator_id)
      self.updater_id = result
      result
    end

    skip_saving_unless_valid
  end

  transform_table :lesson_plan_entries,
                  to: ::Course::LessonPlan::Event,
                  default_scope: proc { within_courses(course_ids) } do
    primary_key :id
    column to: :course_id do
      V1::Source::Course.transform(source_record.course_id)
    end
    column to: :event_type do
      source_record.transform_entry_type
    end
    column :title
    column :description
    column :location
    column :start_at
    column :end_at
    column to: :published do
      true
    end
    column to: :creator_id do
      result = V1::Source::User.transform(source_record.creator_id)
      self.updater_id = result
      result
    end

    skip_saving_unless_valid
  end
end

# Schema
#
# V2:
# create_table "course_lesson_plan_events", force: :cascade do |t|
#   t.string  "location",   limit: 255
#   t.integer "event_type", default: 0, null: false
# end
#
# create_table "course_lesson_plan_items", force: :cascade do |t|
#   t.integer  "actable_id"
#   t.string   "actable_type",           :limit=>255, :index=>{:name=>"index_course_lesson_plan_items_on_actable_type_and_actable_id", :with=>["actable_id"], :unique=>true}
#   t.integer  "course_id",              :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_course_id"}, :foreign_key=>{:references=>"courses", :name=>"fk_course_lesson_plan_items_course_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.string   "title",                  :limit=>255, :null=>false
#   t.text     "description"
#   t.boolean  "published",              :default=>false, :null=>false
#   t.integer  "base_exp",               :null=>false
#   t.integer  "time_bonus_exp",         :null=>false
#   t.datetime "start_at",               :null=>false
#   t.datetime "bonus_end_at"
#   t.datetime "end_at"
#   t.float    "opening_reminder_token"
#   t.float    "closing_reminder_token"
#   t.integer  "creator_id",             :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_creator_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_items_creator_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.integer  "updater_id",             :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_updater_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_items_updater_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.datetime "created_at",             :null=>false
#   t.datetime "updated_at",             :null=>false
# end
#
# create_table "course_lesson_plan_milestones", force: :cascade do |t|
#   t.integer  "course_id",   :index=>{:name=>"fk__course_lesson_plan_milestones_course_id"}, :foreign_key=>{:references=>"courses", :name=>"fk_course_lesson_plan_milestones_course_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.string   "title",       :limit=>255, :null=>false
#   t.text     "description"
#   t.datetime "start_at",    :null=>false
#   t.integer  "creator_id",  :null=>false, :index=>{:name=>"fk__course_lesson_plan_milestones_creator_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_milestones_creator_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.integer  "updater_id",  :null=>false, :index=>{:name=>"fk__course_lesson_plan_milestones_updater_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_milestones_updater_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.datetime "created_at",  :null=>false
#   t.datetime "updated_at",  :null=>false
# end


# V1
# create_table "lesson_plan_entries", :force => true do |t|
#   t.integer  "course_id"
#   t.integer  "creator_id"
#   t.string   "title"
#   t.integer  "entry_type"
#   t.text     "description"
#   t.datetime "start_at"
#   t.datetime "end_at"
#   t.string   "location"
# end
#
# create_table "lesson_plan_milestones", :force => true do |t|
#   t.integer  "course_id"
#   t.integer  "creator_id"
#   t.string   "title"
#   t.text     "description"
#   t.datetime "end_at"
#   t.datetime "start_at"
#   t.boolean  "is_publish",  :default => true
# end
#
# create_table "lesson_plan_resources", :force => true do |t|
#   t.integer "lesson_plan_entry_id"
#   t.integer "obj_id"
#   t.string  "obj_type"
# end<commit_msg>[Fix] Lesson plan timestamps<commit_after>def transform_lesson_plans(course_ids = [])
  transform_table :lesson_plan_milestones,
                  to: ::Course::LessonPlan::Milestone,
                  default_scope: proc { within_courses(course_ids) } do
    primary_key :id
    column to: :course_id do
      V1::Source::Course.transform(source_record.course_id)
    end
    column :title
    column :description
    column :start_at
    column to: :creator_id do
      result = V1::Source::User.transform(source_record.creator_id)
      self.updater_id = result
      result
    end

    column to: :created_at do
      Time.zone.now
    end
    column to: :updated_at do
      Time.zone.now
    end

    skip_saving_unless_valid
  end

  transform_table :lesson_plan_entries,
                  to: ::Course::LessonPlan::Event,
                  default_scope: proc { within_courses(course_ids) } do
    primary_key :id
    column to: :course_id do
      V1::Source::Course.transform(source_record.course_id)
    end
    column to: :event_type do
      source_record.transform_entry_type
    end
    column :title
    column :description
    column :location
    column :start_at
    column :end_at
    column to: :published do
      true
    end
    column to: :creator_id do
      result = V1::Source::User.transform(source_record.creator_id)
      self.updater_id = result
      result
    end

    column to: :created_at do
      Time.zone.now
    end
    column to: :updated_at do
      Time.zone.now
    end

    skip_saving_unless_valid
  end
end

# Schema
#
# V2:
# create_table "course_lesson_plan_events", force: :cascade do |t|
#   t.string  "location",   limit: 255
#   t.integer "event_type", default: 0, null: false
# end
#
# create_table "course_lesson_plan_items", force: :cascade do |t|
#   t.integer  "actable_id"
#   t.string   "actable_type",           :limit=>255, :index=>{:name=>"index_course_lesson_plan_items_on_actable_type_and_actable_id", :with=>["actable_id"], :unique=>true}
#   t.integer  "course_id",              :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_course_id"}, :foreign_key=>{:references=>"courses", :name=>"fk_course_lesson_plan_items_course_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.string   "title",                  :limit=>255, :null=>false
#   t.text     "description"
#   t.boolean  "published",              :default=>false, :null=>false
#   t.integer  "base_exp",               :null=>false
#   t.integer  "time_bonus_exp",         :null=>false
#   t.datetime "start_at",               :null=>false
#   t.datetime "bonus_end_at"
#   t.datetime "end_at"
#   t.float    "opening_reminder_token"
#   t.float    "closing_reminder_token"
#   t.integer  "creator_id",             :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_creator_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_items_creator_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.integer  "updater_id",             :null=>false, :index=>{:name=>"fk__course_lesson_plan_items_updater_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_items_updater_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.datetime "created_at",             :null=>false
#   t.datetime "updated_at",             :null=>false
# end
#
# create_table "course_lesson_plan_milestones", force: :cascade do |t|
#   t.integer  "course_id",   :index=>{:name=>"fk__course_lesson_plan_milestones_course_id"}, :foreign_key=>{:references=>"courses", :name=>"fk_course_lesson_plan_milestones_course_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.string   "title",       :limit=>255, :null=>false
#   t.text     "description"
#   t.datetime "start_at",    :null=>false
#   t.integer  "creator_id",  :null=>false, :index=>{:name=>"fk__course_lesson_plan_milestones_creator_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_milestones_creator_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.integer  "updater_id",  :null=>false, :index=>{:name=>"fk__course_lesson_plan_milestones_updater_id"}, :foreign_key=>{:references=>"users", :name=>"fk_course_lesson_plan_milestones_updater_id", :on_update=>:no_action, :on_delete=>:no_action}
#   t.datetime "created_at",  :null=>false
#   t.datetime "updated_at",  :null=>false
# end


# V1
# create_table "lesson_plan_entries", :force => true do |t|
#   t.integer  "course_id"
#   t.integer  "creator_id"
#   t.string   "title"
#   t.integer  "entry_type"
#   t.text     "description"
#   t.datetime "start_at"
#   t.datetime "end_at"
#   t.string   "location"
# end
#
# create_table "lesson_plan_milestones", :force => true do |t|
#   t.integer  "course_id"
#   t.integer  "creator_id"
#   t.string   "title"
#   t.text     "description"
#   t.datetime "end_at"
#   t.datetime "start_at"
#   t.boolean  "is_publish",  :default => true
# end
#
# create_table "lesson_plan_resources", :force => true do |t|
#   t.integer "lesson_plan_entry_id"
#   t.integer "obj_id"
#   t.string  "obj_type"
# end
{'fraction_non_alphanumeric': 0.14058865176494387, 'fraction_numerical': 0.0038434307676747242, 'mean_word_length': 3.929212362911266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 143, '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': '6882575', 'n_tokens_mistral': 3691, 'n_tokens_neox': 3619, 'n_words': 592}