forked from GNUsocial/gnu-social
[Nodeinfo] Count active users for full days and without silenced
This commit is contained in:
parent
42aa255152
commit
872bb1388d
@ -327,17 +327,19 @@ class Nodeinfo_2_0Action extends Action
|
|||||||
public function getActiveUsers(int $days): int
|
public function getActiveUsers(int $days): int
|
||||||
{
|
{
|
||||||
$userTable = common_database_tablename('user');
|
$userTable = common_database_tablename('user');
|
||||||
$query = "
|
$query = <<<END
|
||||||
SELECT COUNT(DISTINCT profile_id) AS active_users_count
|
SELECT COUNT(DISTINCT profile_id) AS active_users_count
|
||||||
FROM (
|
FROM (
|
||||||
SELECT profile_id FROM notice
|
SELECT profile_id FROM notice
|
||||||
WHERE notice.created >= (CURRENT_TIMESTAMP - INTERVAL '{$days}' DAY) AND notice.is_local = 1
|
WHERE notice.created >= CURRENT_DATE - INTERVAL '{$days}' DAY AND notice.is_local = 1
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT user_id FROM fave INNER JOIN {$userTable} ON fave.user_id = {$userTable}.id
|
SELECT user_id FROM fave INNER JOIN {$userTable} ON fave.user_id = {$userTable}.id
|
||||||
WHERE fave.created >= (CURRENT_TIMESTAMP - INTERVAL '{$days}' DAY)
|
WHERE fave.created >= CURRENT_DATE - INTERVAL '{$days}' DAY
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT id FROM {$userTable} WHERE {$userTable}.created >= (CURRENT_TIMESTAMP - INTERVAL '{$days}' DAY)
|
SELECT id FROM {$userTable} WHERE {$userTable}.created >= CURRENT_DATE - INTERVAL '{$days}' DAY
|
||||||
) AS source";
|
) AS source
|
||||||
|
WHERE profile_id NOT IN (SELECT profile_id FROM profile_role WHERE role = 'silenced')
|
||||||
|
END;
|
||||||
|
|
||||||
$activeUsersCount = new DB_DataObject();
|
$activeUsersCount = new DB_DataObject();
|
||||||
$activeUsersCount->query($query);
|
$activeUsersCount->query($query);
|
||||||
|
Loading…
Reference in New Issue
Block a user