Skip to content

Automatic archival of old groups

Old groups are archived automatically to save space in RTDB (which is expensive). This is controlled by lastChanged field of each group. This is a multi-step process.

Remind users about unsettled debts in their group

After 32 days of no activity, a reminder is sent to everyone participating in any debts in the given group. This is done by matching members to their corresponding users. Email 07_group-debt-reminder is sent, along with a push notification. The same email and notification is sent when this is triggered manually from the app (Premium feature).

The number 32 days is deliberate because users might have a monthly recurring subscription, so this is designed to not interfere with those.

Remind users their group will be archived

One week before archiving a group its users are notified this will happen. Email 08_group-archive-reminder is sent. Groups whose owner has Premium are skipped, they won't be archived. Groups archived by the sweep (see below) long after they got old don't get the reminder.

Archive old groups

Currently, unsettled groups older than 6 months and settled groups older than 3 months are archived. Premium groups and groups whose owner has Premium are not archived.

This process runs several times a day to decrease the load on the database with a limit for the number of groups archived. Each run reads:

  • the 1000 newest groups older than 6 months, so groups are archived as soon as they get old enough,
  • the 2000 newest groups between 3 and 6 months old, which are archived only when they are settled.

Groups which can't be archived (e.g. the owner has Premium) stay among the 1000 newest forever, so older groups would never be reached. That's why a separate sweep (sweepOldGroupsCron) goes through all groups older than 6 months from the oldest, every 10 minutes in batches of SETTLEUP_GROUP_ARCHIVE_SWEEP_SIZE groups. Each batch continues after the last group of the previous one, stored in /archiveSweepCursor (lastChanged and the group key), and once it gets to the newest, the next batch starts over from the oldest. This also archives groups which can be archived only later, e.g. when the owner's Premium expires.

When archival happens the users are notified via a push notification (regular Change is generated too).