Absence Alerts & At-Risk Thresholds
Kononia implements automatic absence monitoring. When a member misses multiple scheduled services or classes, the system triggers alerts and schedules pastoral check-ins.
1. At-Risk Assessment Trigger
The calculation for consecutive absences is handled directly inside the database via the trg_update_attendance_stats trigger which fires after every attendance update.
Absence Logic Flow
[Attendance Logged]
│
├──► Status ∈ {'present', 'late'}
│ │
│ └──► Reset consecutive_absences = 0
│ Set at_risk_flag = false
│
└──► Status = 'absent'
│
├──► Query threshold from org_settings_kv
│ (Default to 3 if not defined)
│
└──► Increment consecutive_absences
IF consecutive_absences >= threshold:
Set at_risk_flag = true
2. Organization Threshold Configuration
Organizations can adjust the tolerance level before alerts are raised.
- Storage Entity:
public.org_settings_kv - Key Name:
'absence_alert_threshold' - Settings UI: Located under Settings > Attendance & Alerts. Admins can select standard values (e.g., 3, 4, or 6 consecutive absences) which are stored as integers in a JSONB value block.
3. Escolating to Pastoral Care
Once a contact’s at_risk_flag is updated to true, the system escalates the issue automatically.
Nightly Cron Job
The database runs auto_generate_absence_pastoral_cases() every night via pg_cron.
- Target Identification: Searches for members with
at_risk_flag = truewho do not have an open absence case. - Shepherd Assignment: Looks up the member’s household via
family_membersand resolves the shepherd assigned to the family (families.assigned_servant_id). - Pastoral Case Creation: Inserts a new record into
public.pastoral_casescontaining the absentees’ details.- If consecutive absences are $\ge 6$, the priority is marked Urgent.
- If consecutive absences are between the threshold and $5$, the priority is marked Normal.
- Servant Action: The case is assigned directly to the shepherd, appearing on their mobile dashboard as a pending “Absence Follow-up” visitation request.