Remove option "all" for search API. Only local/remote + improved cache
This commit is contained in:
parent
ed2e7c453a
commit
88e0409367
|
@ -31,19 +31,13 @@ $sql_all = '
|
|||
ORDER BY a.updated_at DESC
|
||||
';
|
||||
|
||||
$user_filter = 'all';
|
||||
$user_filter = 'local';
|
||||
if (isset($_GET['user_filter'])) {
|
||||
$user_filter = strtolower(trim($_GET['user_filter']));
|
||||
if (!in_array($user_filter, ['all','local','remote']))
|
||||
$user_filter = 'all';
|
||||
if (!in_array($user_filter, ['local','remote']))
|
||||
$user_filter = 'local';
|
||||
}
|
||||
switch ($user_filter) {
|
||||
case 'all':
|
||||
$sql_all = str_replace('{userFilter}', '', $sql_all);
|
||||
$sql_all = str_replace('{userLocalInnerJoin}', '', $sql_all);
|
||||
$sql_all = str_replace('{userLocalWhere1}', '', $sql_all);
|
||||
$sql_all = str_replace('{userLocalWhere2}', '', $sql_all);
|
||||
break;
|
||||
case 'local':
|
||||
$sql_all = str_replace('{userFilter}', 'a.domain IS NULL AND', $sql_all);
|
||||
$sql_all = str_replace('{userLocalInnerJoin}', 'INNER JOIN users AS u ON u.account_id = a.id', $sql_all);
|
||||
|
@ -70,8 +64,8 @@ else $sql_all = str_replace('{noStatusesWhere}', '', $sql_all);
|
|||
$cache = null;
|
||||
if ($user_filter === 'local')
|
||||
$cache = 'ondemand,60';
|
||||
else if (in_array($user_filter, ['all','remote']))
|
||||
$cache = 'ondemand,300';
|
||||
else if ($user_filter === 'remote')
|
||||
$cache = 'always,3600';
|
||||
|
||||
$all_accounts = $pg->fetch_all($sql_all, $cache);
|
||||
|
||||
|
@ -88,6 +82,7 @@ if (isset($_GET['profile']) && trim($_GET['profile']) != '')
|
|||
$a_note = trim($account['note']);
|
||||
$a_fields = json_decode($account['fields'], true);
|
||||
$fields = '';
|
||||
if (gettype($a_fields) === 'array')
|
||||
foreach ($a_fields as $field)
|
||||
$fields .= $field['name'].' '.$field['value'].' ';
|
||||
$a_note = trim($fields) . $a_note;
|
||||
|
|
Loading…
Reference in New Issue