artisan cron job for automatically rejecting
approved datasets
This commit is contained in:
parent
03bcbab560
commit
390f6bbef8
6 changed files with 193 additions and 100 deletions
66
app/Console/Commands/DatasetState.php
Normal file
66
app/Console/Commands/DatasetState.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
//php artisan make:command DatasetState
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DatasetState extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'state:dataset';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check dataset state';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// calculate new statistics
|
||||
// $datasets = DB::table('documents')
|
||||
// ->select('account_id', DB::raw('count(*) as total_posts'))
|
||||
// ->groupBy('account_id')
|
||||
// ->get();
|
||||
|
||||
$datasets = DB::table('documents')
|
||||
->select('id', 'account_id')
|
||||
->where('server_state', 'approved')
|
||||
->whereRaw('server_date_modified < DATEADD(day,-14,GETDATE())')
|
||||
->get();
|
||||
|
||||
// update statistics table
|
||||
foreach ($datasets as $dataset) {
|
||||
// DB::table('users_statistics')
|
||||
// ->where('user_id', $dataset->user_id)
|
||||
// ->update(['total_datasets' => $dataset->total_posts]);
|
||||
DB::table('documents')
|
||||
->where('id', $dataset->id)
|
||||
->update([
|
||||
'reject_reviewer_note' => 'Dataset was automatically rejected because of the time limit',
|
||||
'server_state' => 'rejected_reviewer'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +1,33 @@
|
|||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
||||
class Inspire extends Command {
|
||||
class Inspire extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,27 +3,45 @@
|
|||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel {
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
'App\Console\Commands\DatasetState'
|
||||
];
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
];
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//$schedule->command('inspire')->hourly();
|
||||
// $schedule->command('inspire')
|
||||
// ->everyMinute()
|
||||
// ->appendOutputTo(storage_path('logs/inspire.log'));
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inspire')
|
||||
->hourly();
|
||||
}
|
||||
$schedule->command('state:dataset');
|
||||
//->appendOutputTo(storage_path('logs/inspire.log'));
|
||||
|
||||
|
||||
//->everyThirtyMinutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Closure based commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue