Browse Source

add users room activity totals, sort user list by posts DESC

main
ghost 11 months ago
parent
commit
f8ce625877
  1. 53
      src/Controller/UserController.php
  2. 1
      templates/default/module/rooms.html.twig
  3. 16
      templates/default/user/list.html.twig

53
src/Controller/UserController.php

@ -76,10 +76,28 @@ class UserController extends AbstractController
continue; 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[] = $list[] =
[ [
'name' => $user['key'], 'name' => $user['key'],
'height' => $user['height'], 'total' => $total,
'rooms' => $rooms,
]; ];
} }
} }
@ -89,9 +107,9 @@ class UserController extends AbstractController
array_multisort( array_multisort(
array_column( array_column(
$list, $list,
'height' 'total'
), ),
SORT_ASC, SORT_DESC,
$list $list
); );
@ -716,6 +734,35 @@ class UserController extends AbstractController
return null; 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( private function _hash(
\Kevachat\Kevacoin\Client $client, \Kevachat\Kevacoin\Client $client,
string $namespace, string $namespace,

1
templates/default/module/rooms.html.twig

@ -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"/> <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> </svg></a>
</sup> </sup>
&bull;
<h2> <h2>
<i> <i>
{% if 'user_list' == request.get('_route') %} {% if 'user_list' == request.get('_route') %}

16
templates/default/user/list.html.twig

@ -7,11 +7,19 @@
<li> <li>
<div> <div>
<strong> <strong>
{{ user.name }} @{{ user.name }}
</strong> </strong>
<i style="float:right">{# @TODO #} <span style="float:right">{# @TODO #}
{#{{ 'at block' | trans }}#} {{ user.height }} {% for namespace, total in user.rooms %}
</i> <a href="{{
path('room_namespace',
{
mode : request.get('mode'),
namespace : namespace, _fragment : 'latest'
}) }}">{{ namespace | keva_namespace_value }}</a>
{{ total }}
{% endfor %}
</span>
</div> </div>
</li> </li>
{% endfor %} {% endfor %}

Loading…
Cancel
Save