summaryrefslogtreecommitdiffstats
path: root/lib/Command
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-01-24 10:24:17 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-01-24 10:50:03 -0100
commitfd2ef9e6cec67b6a50b91293d97831d3631d9f26 (patch)
tree5cc84479070e84ce07f23e5b069998edc5ecd202 /lib/Command
parentd685af4008e3f337e2887a04253814d8a9a4dc5b (diff)
cleaning and renaming upsteam request caching
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/QueueProcess.php59
-rw-r--r--lib/Command/QueueStatus.php14
2 files changed, 56 insertions, 17 deletions
diff --git a/lib/Command/QueueProcess.php b/lib/Command/QueueProcess.php
index 20ea8f14..69006183 100644
--- a/lib/Command/QueueProcess.php
+++ b/lib/Command/QueueProcess.php
@@ -36,7 +36,8 @@ use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
+use OCA\Social\Service\StreamQueueService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -47,8 +48,11 @@ class QueueProcess extends Base {
/** @var ActivityService */
private $activityService;
- /** @var QueueService */
- private $queueService;
+ /** @var StreamQueueService */
+ private $streamQueueService;
+
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var ConfigService */
private $configService;
@@ -61,18 +65,21 @@ class QueueProcess extends Base {
* NoteCreate constructor.
*
* @param ActivityService $activityService
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
+ * @param StreamQueueService $streamQueueService
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
- ActivityService $activityService, QueueService $queueService, ConfigService $configService,
+ ActivityService $activityService, RequestQueueService $requestQueueService,
+ StreamQueueService $streamQueueService, ConfigService $configService,
MiscService $miscService
) {
parent::__construct();
$this->activityService = $activityService;
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
+ $this->streamQueueService = $streamQueueService;
$this->configService = $configService;
$this->miscService = $miscService;
}
@@ -94,14 +101,24 @@ class QueueProcess extends Base {
*/
protected function execute(InputInterface $input, OutputInterface $output) {
- $requests = $this->queueService->getRequestStandby($total = 0);
+ $output->writeLn('processing requests queue');
+ $this->processRequestQueue($output);
+
+ $output->writeLn('processing stream queue');
+ $this->processStreamQueue($output);
+ }
+
+
+ private function processRequestQueue(OutputInterface $output) {
+ $total = 0;
+ $requests = $this->requestQueueService->getRequestStandby($total);
- $output->writeLn('found a total of ' . $total . ' requests in the queue');
+ $output->writeLn('- found a total of ' . $total . ' requests in the queue');
if ($total === 0) {
return;
}
- $output->writeLn(sizeof($requests) . ' are processable at this time');
+ $output->writeLn('- ' . sizeof($requests) . ' are processable at this time');
if (sizeof($requests) === 0) {
return;
}
@@ -119,5 +136,27 @@ class QueueProcess extends Base {
$output->writeLn('done');
}
-}
+ private function processStreamQueue(OutputInterface $output) {
+ $total = 0;
+ $items = $this->streamQueueService->getRequestStandby($total);
+
+ $output->writeLn('- found a total of ' . $total . ' not cached object in the queue');
+ if ($total === 0) {
+ return;
+ }
+
+ $output->writeLn('- ' . sizeof($items) . ' are processable at this time');
+ if (sizeof($items) === 0) {
+ return;
+ }
+
+ foreach ($items as $item) {
+ $output->write('.');
+ $this->streamQueueService->manageStreamQueue($item);
+ }
+
+ $output->writeLn('done');
+ }
+
+}
diff --git a/lib/Command/QueueStatus.php b/lib/Command/QueueStatus.php
index 932b7ea2..baa85c0b 100644
--- a/lib/Command/QueueStatus.php
+++ b/lib/Command/QueueStatus.php
@@ -34,7 +34,7 @@ use Exception;
use OC\Core\Command\Base;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
-use OCA\Social\Service\QueueService;
+use OCA\Social\Service\RequestQueueService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -46,8 +46,8 @@ class QueueStatus extends Base {
/** @var ConfigService */
private $configService;
- /** @var QueueService */
- private $queueService;
+ /** @var RequestQueueService */
+ private $requestQueueService;
/** @var MiscService */
private $miscService;
@@ -56,16 +56,16 @@ class QueueStatus extends Base {
/**
* NoteCreate constructor.
*
- * @param QueueService $queueService
+ * @param RequestQueueService $requestQueueService
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
- QueueService $queueService, ConfigService $configService, MiscService $miscService
+ RequestQueueService $requestQueueService, ConfigService $configService, MiscService $miscService
) {
parent::__construct();
- $this->queueService = $queueService;
+ $this->requestQueueService = $requestQueueService;
$this->configService = $configService;
$this->miscService = $miscService;
}
@@ -98,7 +98,7 @@ class QueueStatus extends Base {
throw new Exception('As of today, --token is mandatory');
}
- $requests = $this->queueService->getRequestFromToken($token);
+ $requests = $this->requestQueueService->getRequestFromToken($token);
foreach ($requests as $request) {
$output->writeLn(json_encode($request));