+ /**
+ * Display a single line about reading stats.
+ *
+ * @return string
+ */
+ public function displayStats()
+ {
+ $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
+
+ if (null === $user || !is_object($user)) {
+ return 0;
+ }
+
+ $query = $this->entryRepository->getBuilderForArchiveByUser($user->getId())
+ ->select('e.id')
+ ->groupBy('e.id')
+ ->getQuery();
+
+ $query->useQueryCache(true);
+ $query->useResultCache(true);
+ $query->setResultCacheLifetime($this->lifeTime);
+
+ $nbArchives = count($query->getArrayResult());
+
+ $interval = $user->getCreatedAt()->diff(new \DateTime('now'));
+ $nbDays = (int) $interval->format('%a') ?: 1;
+
+ // force setlocale for date translation
+ setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage())));
+
+ return $this->translator->trans('footer.stats', [
+ '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()),
+ '%nb_archives%' => $nbArchives,
+ '%per_day%' => round($nbArchives / $nbDays, 2),
+ ]);
+ }
+