3 namespace Wallabag\ImportBundle\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
6 use Symfony\Component\Routing\Annotation\Route
;
8 class ImportController
extends Controller
11 * @Route("/", name="import")
13 public function importAction()
15 return $this->render('WallabagImportBundle:Import:index.html.twig', [
16 'imports' => $this->get('wallabag_import.chain')->getAll(),
21 * Display how many messages are queue (both in Redis and RabbitMQ).
24 public function checkQueueAction()
26 $nbRedisMessages = null;
27 $nbRabbitMessages = null;
28 $redisNotInstalled = false;
29 $rabbitNotInstalled = false;
31 if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
32 return $this->render('WallabagImportBundle:Import:check_queue.html.twig');
35 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
36 // in case rabbit is activated but not installed
38 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
39 +
$this->getTotalMessageInRabbitQueue('readability')
40 +
$this->getTotalMessageInRabbitQueue('wallabag_v1')
41 +
$this->getTotalMessageInRabbitQueue('wallabag_v2')
42 +
$this->getTotalMessageInRabbitQueue('firefox')
43 +
$this->getTotalMessageInRabbitQueue('chrome')
44 +
$this->getTotalMessageInRabbitQueue('instapaper')
45 +
$this->getTotalMessageInRabbitQueue('pinboard')
46 +
$this->getTotalMessageInRabbitQueue('elcurator')
48 } catch (\Exception
$e) {
49 $rabbitNotInstalled = true;
51 } elseif ($this->get('craue_config')->get('import_with_redis')) {
52 $redis = $this->get('wallabag_core.redis.client');
55 $nbRedisMessages = $redis->llen('wallabag.import.pocket')
56 +
$redis->llen('wallabag.import.readability')
57 +
$redis->llen('wallabag.import.wallabag_v1')
58 +
$redis->llen('wallabag.import.wallabag_v2')
59 +
$redis->llen('wallabag.import.firefox')
60 +
$redis->llen('wallabag.import.chrome')
61 +
$redis->llen('wallabag.import.instapaper')
62 +
$redis->llen('wallabag.import.pinboard')
63 +
$redis->llen('wallabag.import.elcurator')
65 } catch (\Exception
$e) {
66 $redisNotInstalled = true;
70 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
71 'nbRedisMessages' => $nbRedisMessages,
72 'nbRabbitMessages' => $nbRabbitMessages,
73 'redisNotInstalled' => $redisNotInstalled,
74 'rabbitNotInstalled' => $rabbitNotInstalled,
79 * Count message in RabbitMQ queue.
80 * It get one message without acking it (so it'll stay in the queue)
81 * which will include the total of *other* messages in the queue.
82 * Adding one to that messages will result in the full total message.
84 * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
88 private function getTotalMessageInRabbitQueue($importService)
91 ->get('old_sound_rabbit_mq.import_' . $importService . '_consumer')
93 ->basic_get('wallabag.import.' . $importService);
95 if (null === $message) {
99 return $message->delivery_info
['message_count'] +
1;