From 23c8d4169976c0c56d803d01db6381db75d5e0ba Mon Sep 17 00:00:00 2001 From: Peter Dulacka Date: Tue, 30 Apr 2019 13:38:58 +0200 Subject: [PATCH] Adding ProcessPageviewSessions to Beam's console Kernel This command was unintentionally omitted from Kernel and the default installation doesn't have any session/device data because of that. Even though it's still possible to run the command manually, this shouldn't be visible to the user/admin and it should be consistent with the rest of command suite. --- .../app/Console/Commands/ProcessPageviewSessions.php | 12 +++++++----- Beam/app/Console/Kernel.php | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Beam/app/Console/Commands/ProcessPageviewSessions.php b/Beam/app/Console/Commands/ProcessPageviewSessions.php index 8734d1616..a24a74ebd 100644 --- a/Beam/app/Console/Commands/ProcessPageviewSessions.php +++ b/Beam/app/Console/Commands/ProcessPageviewSessions.php @@ -13,7 +13,9 @@ class ProcessPageviewSessions extends Command { - protected $signature = 'pageviews:process-sessions {--now=}'; + const COMMAND = 'pageviews:process-sessions'; + + protected $signature = self::COMMAND . ' {--now=}'; protected $description = 'Reads and parses session referers tracked within Beam'; @@ -59,7 +61,7 @@ public function handle( ]; $bar = $this->output->createProgressBar(count($pageviews)); - $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'); + $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%'); $bar->setMessage('Detecting devices and sources'); foreach ($pageviews as $record) { @@ -67,7 +69,7 @@ public function handle( continue; } $pageview = $record->pageviews[0]; - + $deviceDetector->setUserAgent($pageview->user->user_agent); $deviceDetector->parse(); @@ -115,7 +117,7 @@ public function handle( $deviceConditionsAndCounts = $this->conditionAndCounts($deviceAggregate, $deviceBlueprint); if (count($deviceConditionsAndCounts) > 0) { $bar = $this->output->createProgressBar(count($deviceConditionsAndCounts)); - $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'); + $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%'); $bar->setMessage('Storing device data'); foreach ($deviceConditionsAndCounts as $device) { @@ -138,7 +140,7 @@ public function handle( $refererConditionsAndCounts = $this->conditionAndCounts($refererAggregate, $refererBlueprint); if (count($refererConditionsAndCounts) > 0) { $bar = $this->output->createProgressBar(count($refererConditionsAndCounts)); - $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'); + $bar->setFormat('%message%: %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%'); $bar->setMessage('Storing referer data'); foreach ($refererConditionsAndCounts as $referer) { diff --git a/Beam/app/Console/Kernel.php b/Beam/app/Console/Kernel.php index 507cc1e31..03a398ed5 100644 --- a/Beam/app/Console/Kernel.php +++ b/Beam/app/Console/Kernel.php @@ -8,6 +8,7 @@ use App\Console\Commands\AggregatePageviewTimespentJob; use App\Console\Commands\ComputeAuthorsSegments; use App\Console\Commands\DeleteOldAggregations; +use App\Console\Commands\ProcessPageviewSessions; use App\Console\Commands\SendNewslettersCommand; use App\Console\Commands\CompressAggregations; use Illuminate\Console\Scheduling\Schedule; @@ -48,6 +49,10 @@ protected function schedule(Schedule $schedule) ->hourlyAt(4) ->withoutOverlapping(); + $schedule->command(ProcessPageviewSessions::COMMAND) + ->hourlyAt(5) + ->withoutOverlapping(); + $schedule->command(DeleteOldAggregations::COMMAND) ->dailyAt('00:10') ->withoutOverlapping();