<commit_before>module SerializeDataHelper

  def serialize_intervention(intervention)
    {
      id: intervention.id,
      name: intervention.name,
      intervention_type_id: intervention.intervention_type_id,
      comment: intervention.comment,
      goal: intervention.goal,
      start_date: intervention.start_date.strftime('%B %e, %Y'), # profile v1
      start_date_timestamp: intervention.start_date,
      end_date: intervention.end_date.try(:strftime, '%B %e, %Y'), # profile v1
      educator_email: intervention.educator.try(:email), # profile v1
      educator_id: intervention.educator.try(:id),
      progress_notes: intervention.progress_notes.order(created_at: :asc).map do |progress_note|
        serialize_progress_note(progress_note)
      end
    }
  end

  def serialize_progress_note(progress_note)
    {
      id: progress_note.id,
      educator_email: progress_note.educator.email,
      educator_id: intervention.educator.id,
      content: progress_note.content,
      created_date: progress_note.created_at.strftime("%B %e, %Y %l:%M %p")
    }
  end

  def serialize_student_note(student_note)
    {
      id: student_note.id,
      content: student_note.content,
      educator_id: student_note.educator.id,
      educator_email: student_note.educator.email,
      created_at_timestamp: student_note.created_at,
      created_at: student_note.created_at.strftime('%B %e, %Y')
    }
  end

  # Used to send down all intervention types, for lookups from student records
  def intervention_types_index
    index = {}
    InterventionType.all.each do |intervention_type|
      index[intervention_type.id] = intervention_type
    end
    index
  end

  # Used to send down all educators, for lookups from other records
  def educators_index<commit_msg>Fix typo bug in serialize_data_helper<commit_after>module SerializeDataHelper

  def serialize_intervention(intervention)
    {
      id: intervention.id,
      name: intervention.name,
      intervention_type_id: intervention.intervention_type_id,
      comment: intervention.comment,
      goal: intervention.goal,
      start_date: intervention.start_date.strftime('%B %e, %Y'), # profile v1
      start_date_timestamp: intervention.start_date,
      end_date: intervention.end_date.try(:strftime, '%B %e, %Y'), # profile v1
      educator_email: intervention.educator.try(:email), # profile v1
      educator_id: intervention.educator.try(:id),
      progress_notes: intervention.progress_notes.order(created_at: :asc).map do |progress_note|
        serialize_progress_note(progress_note)
      end
    }
  end

  def serialize_progress_note(progress_note)
    {
      id: progress_note.id,
      educator_email: progress_note.educator.email,
      educator_id: progress_note.educator.id,
      content: progress_note.content,
      created_date: progress_note.created_at.strftime("%B %e, %Y %l:%M %p")
    }
  end

  def serialize_student_note(student_note)
    {
      id: student_note.id,
      content: student_note.content,
      educator_id: student_note.educator.id,
      educator_email: student_note.educator.email,
      created_at_timestamp: student_note.created_at,
      created_at: student_note.created_at.strftime('%B %e, %Y')
    }
  end

  # Used to send down all intervention types, for lookups from student records
  def intervention_types_index
    index = {}
    InterventionType.all.each do |intervention_type|
      index[intervention_type.id] = intervention_type
    end
    index
  end

  # Used to send down all educators, for lookups from other records
  def educators_index
{'fraction_non_alphanumeric': 0.08926080892608089, 'fraction_numerical': 0.0016736401673640166, 'mean_word_length': 3.6631989596879064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6522642', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1088, 'n_words': 229}