Skip to content

Commit

Permalink
Adding ProcessPageviewSessions to Beam's console Kernel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rootpd committed Apr 30, 2019
1 parent 9423ce8 commit 23c8d41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Beam/app/Console/Commands/ProcessPageviewSessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -59,15 +61,15 @@ 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) {
if (empty($record->pageviews)) {
continue;
}
$pageview = $record->pageviews[0];

$deviceDetector->setUserAgent($pageview->user->user_agent);
$deviceDetector->parse();

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions Beam/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 23c8d41

Please sign in to comment.