app/lib/profile_insights.rb
# Take only the most recent surey from the most recent upload
Take only the most recent surey from the most recent upload
Take only the most recent surey from the most recent upload
def student_voice_survey_insights
    most_recent_upload = StudentVoiceSurveyUpload
      .where(completed: true)
      .order(created_at: :desc)
      .limit(1)
      .first
    return [] if most_recent_upload.nil?
    most_recent_survey = most_recent_upload.student_voice_completed_surveys
      .where(student_id: @student.id)
      .order(form_timestamp: :desc)
      .limit(1)
      .first
    return [] if most_recent_survey.nil?
    profile_insights_from_survey(most_recent_survey)
  end
def student_voice_survey_insights most_recent_upload = StudentVoiceSurveyUpload . where ( completed : true ) . order ( created_at : :desc ) . limit ( 1 ) . first return [ ] if most_recent_upload . nil? most_recent_survey = most_recent_upload . student_voice_completed_surveys . where ( student_id : @student . id ) . order ( form_timestamp : :desc ) . limit ( 1 ) . first return [ ] if most_recent_survey . nil? profile_insights_from_survey ( most_recent_survey ) end
Take only the most recent surey from the most recent upload
Take only the most recent surey from the most recent upload