<commit_before>class ClassroomActivitiesToUnitActivitiesAndClassroomUnitsWorker
  include Sidekiq::Worker

  def perform(unit_id)
    ClassroomActivity.unscoped.where(unit_id: unit_id).each do |ca|
      if Classroom.unscoped.find_by(id: ca.classroom_id) && ca.unit_id && ca.activity_id && ca.classroom_id
        begin
          ua = UnitActivity.find_or_create_by(
            unit_id: ca.unit_id,
            activity_id: ca.activity_id
          )
          ua.update(
            visible: ca.visible,
            due_date: ca.due_date
          ) if ua

          cu = ClassroomUnit.find_or_create_by(
            unit_id: ca.unit_id,
            classroom_id: ca.classroom_id
          )
          cu.update(
            visible: ca.visible,
            assigned_student_ids: ca.assigned_student_ids,
            assign_on_join: ca.assign_on_join
          ) if cu

          if cu && cu.id
            ca.activity_sessions.update_all(classroom_unit_id: cu.id)
          end

          if ca.activity.is_lesson? && cu && ua && cu.id && ua.id
            ClassroomUnitActivityState.find_or_create_by(
              unit_activity_id: ua.id,
              classroom_unit_id: cu.id,
              pinned: ca.pinned,
              locked: ca.locked,
              completed: ca.completed
            )
          end
        rescue Exception => e
          puts e.message
        end
      end
    end
  end

end<commit_msg>update worker to not run callbacks on unit activities<commit_after>class ClassroomActivitiesToUnitActivitiesAndClassroomUnitsWorker
  include Sidekiq::Worker

  def perform(unit_id)
    UnitActivity.skip_callback(:save, :after, :teacher_checkbox)
    ClassroomActivity.unscoped.where(unit_id: unit_id).each do |ca|
      if Classroom.unscoped.find_by(id: ca.classroom_id) && ca.unit_id && ca.activity_id && ca.classroom_id
        begin
          ua = UnitActivity.find_or_initialize_by(
            unit_id: ca.unit_id,
            activity_id: ca.activity_id
          )
          ua.update(
            visible: ca.visible,
            due_date: ca.due_date
          ) if ua

          cu = ClassroomUnit.find_or_create_by(
            unit_id: ca.unit_id,
            classroom_id: ca.classroom_id
          )
          cu.update(
            visible: ca.visible,
            assigned_student_ids: ca.assigned_student_ids,
            assign_on_join: ca.assign_on_join
          ) if cu

          if cu && cu.id
            ca.activity_sessions.update_all(classroom_unit_id: cu.id)
          end

          if ca.activity.is_lesson? && cu && ua && cu.id && ua.id
            ClassroomUnitActivityState.find_or_create_by(
              unit_activity_id: ua.id,
              classroom_unit_id: cu.id,
              pinned: ca.pinned,
              locked: ca.locked,
              completed: ca.completed
            )
          end
        rescue Exception => e
          puts e.message
        end

      end
    end
    UnitActivity.set_callback(:save, :after, :teacher_checkbox)
  end

end
{'fraction_non_alphanumeric': 0.07743216412971542, 'fraction_numerical': 0.0, 'mean_word_length': 1.783609576427256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5330794', 'n_tokens_mistral': 935, 'n_tokens_neox': 931, 'n_words': 171}