Improve the database query
Improve the database query

The previous version of the query relied on MariaDB/MySQL-specific quirks and
on incorrect GROUP BY behaviour (all fields that should either appear in the
GROUP BY clause or be passed to an aggregate function).

Validation of the interval can be done easier with filter_var, and calculation
of the stale date – directly in SQL.

chimo/gs-staleAccounts