mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-22 12:34:25 +00:00
add users room activity totals, sort user list by posts DESC
This commit is contained in:
parent
b3ee1f1af6
commit
f8ce625877
@ -76,10 +76,28 @@ class UserController extends AbstractController
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get room stats
|
||||
$total = 0;
|
||||
$rooms = [];
|
||||
|
||||
foreach ($this->_rooms($client) as $room => $name)
|
||||
{
|
||||
$posts = 0;
|
||||
|
||||
foreach ((array) $client->kevaFilter($room, sprintf('^[\d]+@%s$', $user['key'])) as $post)
|
||||
{
|
||||
$total++;
|
||||
$posts++;
|
||||
|
||||
$rooms[$room] = $posts;
|
||||
}
|
||||
}
|
||||
|
||||
$list[] =
|
||||
[
|
||||
'name' => $user['key'],
|
||||
'height' => $user['height'],
|
||||
'total' => $total,
|
||||
'rooms' => $rooms,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -89,9 +107,9 @@ class UserController extends AbstractController
|
||||
array_multisort(
|
||||
array_column(
|
||||
$list,
|
||||
'height'
|
||||
'total'
|
||||
),
|
||||
SORT_ASC,
|
||||
SORT_DESC,
|
||||
$list
|
||||
);
|
||||
|
||||
@ -716,6 +734,35 @@ class UserController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
private function _rooms(
|
||||
\Kevachat\Kevacoin\Client $client
|
||||
): array
|
||||
{
|
||||
$rooms = [];
|
||||
|
||||
foreach ((array) $client->kevaListNamespaces() as $value)
|
||||
{
|
||||
if (empty($value['namespaceId']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($value['displayName']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_starts_with($value['displayName'], '_'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$rooms[$value['namespaceId']] = $value['displayName'];
|
||||
}
|
||||
|
||||
return $rooms;
|
||||
}
|
||||
|
||||
private function _hash(
|
||||
\Kevachat\Kevacoin\Client $client,
|
||||
string $namespace,
|
||||
|
@ -35,6 +35,7 @@
|
||||
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm1.5 2.5c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1 0-2m0 4a6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1 0-2m.5 7a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"/>
|
||||
</svg></a>
|
||||
</sup>
|
||||
•
|
||||
<h2>
|
||||
<i>
|
||||
{% if 'user_list' == request.get('_route') %}
|
||||
|
@ -7,11 +7,19 @@
|
||||
<li>
|
||||
<div>
|
||||
<strong>
|
||||
{{ user.name }}
|
||||
@{{ user.name }}
|
||||
</strong>
|
||||
<i style="float:right">{# @TODO #}
|
||||
{#{{ 'at block' | trans }}#} {{ user.height }}
|
||||
</i>
|
||||
<span style="float:right">{# @TODO #}
|
||||
{% for namespace, total in user.rooms %}
|
||||
<a href="{{
|
||||
path('room_namespace',
|
||||
{
|
||||
mode : request.get('mode'),
|
||||
namespace : namespace, _fragment : 'latest'
|
||||
}) }}">{{ namespace | keva_namespace_value }}</a>
|
||||
{{ total }}
|
||||
{% endfor %}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user