Skip to content

Commit

Permalink
fix incorrect top-5 customers in traffic overview for admins; show ma…
Browse files Browse the repository at this point in the history
…nual update command if webupdate is disabled

Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Jan 19, 2024
1 parent 8304701 commit bc1892d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Froxlor/Traffic/Traffic.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public static function getCustomerStats(array $userinfo, string $range = null, b
$years_avail = $sel_stmt->fetchAll(\PDO::FETCH_ASSOC);
}

// sort users by total traffic
usort($users, function ($user_a, $user_b) {
if ($user_a['total'] == $user_b['total']) {
return 0;
}
return ($user_a['total'] < $user_b['total']) ? 1 : -1;
});

return [
'metrics' => $metrics,
'users' => $users,
Expand Down
3 changes: 3 additions & 0 deletions templates/Froxlor/misc/version_popover.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<p>{{ message }}</p>
{% if get_config('enable_webupdate') %}
<a class='btn d-block btn-outline-warning' href='admin_autoupdate.php?page=overview'>Open updater</a>
{% else %}
<p>Run the following command in your shell to update:</p>
<code>{{ call_static('\\Froxlor\\Froxlor', 'getInstallDir') }}bin/froxlor-cli froxlor:update</code>
{% endif %}
{% endif %}
{% endmacro %}
2 changes: 1 addition & 1 deletion templates/Froxlor/user/traffic.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
{% if userinfo.adminsession == 1 %}
const labelsC = [];
const dataValues = [];
{% for user in users|sort((a, b) => a.total <=> b.total)|slice(0, 5) %}
{% for user in users|slice(0, 5) %}
labelsC.push('{{ user.loginname }}');
dataValues.push({value: '{{ user.total|default(0) }}', formatted: '{{ user.total|formatBytes }}'});
{% endfor %}
Expand Down

0 comments on commit bc1892d

Please sign in to comment.