Skip to content

use Participation.updated_at to calculate age statistics bucket

Bengfort requested to merge 2038-age-statistics into main

Currently we use today's date to calculate age statistics. So if recruitment goes on for several month, subjects who have been recruited at the beginning may end up in different buckets than what they started in. This is especially a problem with children, as their buckets are smaller.

My proposal here is to use Participation.updated_at to calculate the age instead. The Participation model itself does not contain a lot of data, so updated_at usually only changed when the status changed (e.g. when set to INVITED). It is not changed e.g. when an appointment is updated. However, it does change when news interest is updated or when the participation is saved without any changes (from a user's perspective there is no big difference between submit and cancel in that case). So all in all updated_at is the same as "when was this subject invited" for most invited participations, but not for all. But still better than the current approach.

Another proposal was to use the date of the first appointment. However, there can be participations without appointments. We would need a fallback for those. That increases complexity.

Note that "sort by statistics" does not sort by buckets but by underlying values. So the displayed values and the sorting would no longer match. I am not really sure what to do about that yet.

Merge request reports