app/lib/insight_students_with_high_absences.rb
# Returns a list of all students that the educator has access
# to that have a high number of absences, but haven't been
# commented on in Insights yet.  This information may not be directly
# actionable for all teachers (eg, ninth grade math teachers) but
# for SST team members, principals and APs, redirect, and K8
# classroom teachers, the intended actions are to talk with
# the student, parent, or refer for SST.
#
# time_threshold and absences_threshold are both inclusive ("greater
# than or equal to")
#
# This method returns hashes that are the shape of what is needed
# in the product.
Returns a list of all students that the educator has access
to that have a high number of absences, but haven't been
commented on in Insights yet.  This information may not be directly
actionable for all teachers  but
for SST team members, principals and APs, redirect, and K8
classroom teachers, the intended actions are to talk with
the student, parent, or refer for SST.

time_threshold and absences_threshold are both inclusive ("greater
than or equal to")

This method returns hashes that are the shape of what is needed
in the product.
Returns a list of all students that the educator has access to that have a high number of absences but haven ' t been commented on in Insights yet . This information may not be directly actionable for all teachers but for SST team members principals and APs redirect and K8 classroom teachers the intended actions are to talk with the student parent or refer for SST . time_threshold and absences_threshold are both inclusive ( " greater than or equal to " ) This method returns hashes that are the shape of what is needed in the product .
def students_with_high_absences_json(time_now, time_threshold, absences_threshold)
    students = @authorizer.authorized do
      students_to_consider = Student.active.where.not(grade: [
        'TK',
        'PPK',
        'PK',
        'OPK',
        'OOPK'
      ])
      FeedFilter.new(@educator).filter_for_educator(students_to_consider)
    end
    student_ids = students.map(&:id)
    absence_count_pairs = absence_counts_for_students(student_ids, time_threshold, absences_threshold)
    commented_student_ids = recently_commented_student_ids(student_ids, time_threshold)
    uncommented_pairs = absence_count_pairs.select do |pair|
      !commented_student_ids.include?(pair[:student].id)
    end
    sorted_students_json(uncommented_pairs)
  end
def students_with_high_absences_json ( time_now , time_threshold , absences_threshold ) students = @authorizer . authorized do students_to_consider = Student . active . where . not ( grade : [ 'TK' , 'PPK' , 'PK' , 'OPK' , 'OOPK' ] ) FeedFilter . new ( @educator ) . filter_for_educator ( students_to_consider ) end student_ids = students . map ( & :id ) absence_count_pairs = absence_counts_for_students ( student_ids , time_threshold , absences_threshold ) commented_student_ids = recently_commented_student_ids ( student_ids , time_threshold ) uncommented_pairs = absence_count_pairs . select do | pair | ! commented_student_ids . include? ( pair [ :student ] . id ) end sorted_students_json ( uncommented_pairs ) end
Returns a list of all students that the educator has access
to that have a high number of absences, but haven't been
commented on in Insights yet.
Returns a list of all students that the educator has access to that have a high number of absences but haven ' t been commented on in Insights yet .
# Exclude students in younger grades like PreK since attendance isn't mandatory. # This means there's less consistent attendance from families, and it's less # of a priority to follow-up for schools. # Filter students to match what they see in their feed (eg, HS counselors # only see students on their caseload). # Absences by student in the time period. # Query for uncommented students, then filter out students with # high absences who have been commented on. # Sort and serialize
time_now
<not_specific>
time_threshold
<not_specific>
absences_threshold
<not_specific>