Add last_n_active to limit db query by the latest N active users
This commit is contained in:
parent
2c118b54bf
commit
1cff51370f
|
@ -55,6 +55,7 @@ $sql_all = '
|
|||
{newerThanNDays}
|
||||
a.suspended_at IS NULL
|
||||
ORDER BY a.updated_at DESC
|
||||
{lastNActiveUsers}
|
||||
';
|
||||
|
||||
$instances = null;
|
||||
|
@ -115,9 +116,20 @@ if (isset($_GET['no_statuses']))
|
|||
else $sql_all = str_replace('{noStatusesWhere}', '', $sql_all);
|
||||
|
||||
|
||||
$last_n_active = null;
|
||||
if (isset($_GET['last_n_active'])) {
|
||||
$last_n_active = intval($_GET['last_n_active']);
|
||||
if ($last_n_active < 0)
|
||||
$last_n_active = 1;
|
||||
}
|
||||
if ($last_n_active !== null)
|
||||
$sql_all = str_replace('{lastNActiveUsers}', 'LIMIT '.intval($_GET['last_n_active']), $sql_all);
|
||||
else $sql_all = str_replace('{lastNActiveUsers}', '', $sql_all);
|
||||
|
||||
|
||||
$only_cached = false;
|
||||
$cache = null;
|
||||
if ($user_filter === 'local')
|
||||
if ($user_filter === 'local' || ($last_n_active !== null && $last_n_active <= 5000))
|
||||
$cache = 'ondemand,60';
|
||||
else if ($user_filter === 'remote') {
|
||||
$cache = 'always,3600';
|
||||
|
|
Loading…
Reference in New Issue