Last events on the main page.
This commit is contained in:
parent
ac297dc0a2
commit
aedc15a204
|
@ -18,6 +18,7 @@ class MainController extends Controller
|
||||||
'subscribers_count' => $em->getRepository('SkobkinPointToolsBundle:Subscription')->getUserSubscribersCountById($this->container->getParameter('point_id')),
|
'subscribers_count' => $em->getRepository('SkobkinPointToolsBundle:Subscription')->getUserSubscribersCountById($this->container->getParameter('point_id')),
|
||||||
'events_count' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getLastDayEventsCount(),
|
'events_count' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getLastDayEventsCount(),
|
||||||
'service_login' => $this->container->getParameter('point_login'),
|
'service_login' => $this->container->getParameter('point_login'),
|
||||||
|
'last_events' => $em->getRepository('SkobkinPointToolsBundle:SubscriptionEvent')->getLastSubscriptionEvents(10),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Entity;
|
namespace Skobkin\Bundle\PointToolsBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
|
|
||||||
class SubscriptionEventRepository extends EntityRepository
|
class SubscriptionEventRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
|
@ -45,4 +46,29 @@ class SubscriptionEventRepository extends EntityRepository
|
||||||
->getQuery()->getResult()
|
->getQuery()->getResult()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get last $limit subscriptions
|
||||||
|
*
|
||||||
|
* @param integer $limit
|
||||||
|
* @return SubscriptionEvent[]
|
||||||
|
*/
|
||||||
|
public function getLastSubscriptionEvents($limit)
|
||||||
|
{
|
||||||
|
if (!is_int($limit)) {
|
||||||
|
throw new \InvalidArgumentException('$limit must be an integer');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb = $this->createQueryBuilder('se');
|
||||||
|
|
||||||
|
return $qb
|
||||||
|
->select()
|
||||||
|
->orderBy('se.date', 'desc')
|
||||||
|
->setMaxResults($limit)
|
||||||
|
->getQuery()
|
||||||
|
->setFetchMode('SkobkinPointToolsBundle:SubscriptionEvent', 'author', ClassMetadata::FETCH_EAGER)
|
||||||
|
->setFetchMode('SkobkinPointToolsBundle:SubscriptionEvent', 'subscriber', ClassMetadata::FETCH_EAGER)
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,9 @@ Source code: Исходный код
|
||||||
All users: Всего пользователей
|
All users: Всего пользователей
|
||||||
Subscribed users: Подписчиков сервиса
|
Subscribed users: Подписчиков сервиса
|
||||||
24 hours events: Событий за сутки
|
24 hours events: Событий за сутки
|
||||||
|
Author: Автор
|
||||||
|
Subscriber: Подписчик
|
||||||
|
Last events: Последние события
|
||||||
|
|
||||||
Username: Имя пользователя
|
Username: Имя пользователя
|
||||||
Search: Поиск
|
Search: Поиск
|
||||||
|
|
|
@ -15,6 +15,58 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{# TODO classes #}
|
||||||
|
<div class="last-subscriptions-log">
|
||||||
|
{% if last_events|length > 0 %}
|
||||||
|
<div class="panel-group" id="accordion-log">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading" id="heading-subscriptions-log">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a data-toggle="collapse" data-parent="#accordion-log" aria-expanded="true" href="#collapse-log">
|
||||||
|
<span class="glyphicon glyphicon-collapse-down"></span> {{ 'Last events'|trans }}
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="collapse-log" class="panel-collapse collapse in" aria-labelledby="heading-subscriptions-log">
|
||||||
|
<div class="panel-body">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'Subscriber'|trans }}</td>
|
||||||
|
<td>{{ 'Author'|trans }}</td>
|
||||||
|
<td>{{ 'Action'|trans }}</td>
|
||||||
|
<td>{{ 'Date'|trans }}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for event in last_events %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url('user_show', {login: event.subscriber.login}) }}">@{{ event.subscriber.login }}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url('user_show', {login: event.author.login}) }}">@{{ event.author.login }}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="glyphicon {% if event.action == 'subscribe' %}glyphicon-plus{% elseif event.action == 'unsubscribe' %}glyphicon-minus{% endif %}"></span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{# Use DateTime helper: https://sonata-project.org/bundles/intl/master/doc/reference/datetime.html #}
|
||||||
|
{{ event.date|date('d F Y H:i:s') }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="alert alert-warning" role="alert">{{ 'No log data found'|trans }}</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="container service-stats">
|
<div class="container service-stats">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-8 col-sm-3"><span class="glyphicon glyphicon-user"></span> {{ 'All users'|trans }}</div>
|
<div class="col-xs-8 col-sm-3"><span class="glyphicon glyphicon-user"></span> {{ 'All users'|trans }}</div>
|
||||||
|
|
Loading…
Reference in a new issue