54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use DB;
|
|
use App\Http\Requests\LambdaRequest;
|
|
|
|
class IndexActivities extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'activity:indexdata';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$activityIndex = DB::connection("primary")->table("activity_index")->where("is_active", 0)->first();
|
|
if($activityIndex) {
|
|
$total = $activityIndex->total_activities;
|
|
for($completed = 0; $completed <= $total; $completed+=10) {
|
|
LambdaRequest::getrequest('catalog', 'activity/step', ['id'=>$activityIndex->import_id, 'step'=>'index_data_chunk', 'start_from' => $completed, 'limit' => 10], env('LAMBDA_ACCESS_TOKEN'));
|
|
DB::connection("primary")->table("activity_index")->where("id", $activityIndex->id)->update(['is_active' => 1, 'indexed_activities' => $completed ]);
|
|
}
|
|
LambdaRequest::getrequest('catalog', 'activity/step', ['id'=>$activityIndex->import_id, 'step'=>'complete'], env('LAMBDA_ACCESS_TOKEN'));
|
|
}
|
|
return 0;
|
|
}
|
|
}
|