<?php

include __DIR__ . '/common.php';
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf;
use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2;
$tmp = \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->select(['count(id) as `count`', '`reseller_id`'])->from('users')->where(['UNIX_TIMESTAMP(keep_alive)>' => \time() - \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\k8281faec2a4a41f470b00112682ddabf::get('watchdog_timeout') * 2])->groupby('reseller_id')->get()->all();
$users_online = [0 => 0];
foreach ($tmp as $row) {
    if (!\array_key_exists((int) $row['reseller_id'], $users_online)) {
        $users_online[(int) $row['reseller_id']] = 0;
    }
    $users_online[(int) $row['reseller_id']] += $row['count'];
}
$users_online['total'] = \array_sum($users_online);
\Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->insert('users_activity', ['users_online' => \json_encode($users_online)]);
