artisan cron job for automatically rejecting

approved datasets
This commit is contained in:
Arno Kaimbacher 2019-05-29 14:04:46 +02:00
parent 03bcbab560
commit 390f6bbef8
6 changed files with 193 additions and 100 deletions

View 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'
]);
}
}
}

View File

@ -1,32 +1,33 @@
<?php namespace App\Console\Commands; <?php
namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
class Inspire extends Command { class Inspire extends Command
{
/** /**
* The console command name. * The console command name.
* *
* @var string * @var string
*/ */
protected $name = 'inspire'; protected $name = 'inspire';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Display an inspiring quote'; protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
} }

View File

@ -3,27 +3,45 @@
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 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. * Define the application's command schedule.
* *
* @var array * @param \Illuminate\Console\Scheduling\Schedule $schedule
*/ * @return void
protected $commands = [ */
'App\Console\Commands\Inspire', protected function schedule(Schedule $schedule)
]; {
//$schedule->command('inspire')->hourly();
// $schedule->command('inspire')
// ->everyMinute()
// ->appendOutputTo(storage_path('logs/inspire.log'));
/** $schedule->command('state:dataset');
* Define the application's command schedule. //->appendOutputTo(storage_path('logs/inspire.log'));
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void //->everyThirtyMinutes();
*/ }
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
} }

View File

@ -301,7 +301,7 @@ class EditorController extends Controller
$input = $request->all(); $input = $request->all();
$input['server_state'] = 'approved'; $input['server_state'] = 'approved';
if ($dataset->reject_reviewer_note != null) { if ($dataset->reject_reviewer_note != null) {
$input['[reject_reviewer_note'] = null; $input['reject_reviewer_note'] = null;
} }
if ($dataset->update($input)) { if ($dataset->update($input)) {

116
composer.lock generated
View File

@ -1696,16 +1696,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81" "reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/e2840bb38bddad7a0feaf85931e38fdcffdb2f81", "url": "https://api.github.com/repos/symfony/console/zipball/7a293c9a4587a92e6a0e81edb0bea54071b1b99d",
"reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81", "reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1764,25 +1764,32 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-04-08T14:23:48+00:00" "time": "2019-05-09T09:19:46+00:00"
}, },
{ {
"name": "symfony/contracts", "name": "symfony/contracts",
"version": "v1.1.0", "version": "v1.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/contracts.git", "url": "https://github.com/symfony/contracts.git",
"reference": "d3636025e8253c6144358ec0a62773cae588395b" "reference": "b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/contracts/zipball/d3636025e8253c6144358ec0a62773cae588395b", "url": "https://api.github.com/repos/symfony/contracts/zipball/b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f",
"reference": "d3636025e8253c6144358ec0a62773cae588395b", "reference": "b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1.3" "php": "^7.1.3"
}, },
"replace": {
"symfony/cache-contracts": "self.version",
"symfony/event-dispatcher-contracts": "self.version",
"symfony/http-client-contracts": "self.version",
"symfony/service-contracts": "self.version",
"symfony/translation-contracts": "self.version"
},
"require-dev": { "require-dev": {
"psr/cache": "^1.0", "psr/cache": "^1.0",
"psr/container": "^1.0", "psr/container": "^1.0",
@ -1791,11 +1798,12 @@
"suggest": { "suggest": {
"psr/cache": "When using the Cache contracts", "psr/cache": "When using the Cache contracts",
"psr/container": "When using the Service contracts", "psr/container": "When using the Service contracts",
"symfony/cache-contracts-implementation": "", "psr/event-dispatcher": "When using the EventDispatcher contracts",
"symfony/cache-implementation": "",
"symfony/event-dispatcher-implementation": "", "symfony/event-dispatcher-implementation": "",
"symfony/http-client-contracts-implementation": "", "symfony/http-client-implementation": "",
"symfony/service-contracts-implementation": "", "symfony/service-implementation": "",
"symfony/translation-contracts-implementation": "" "symfony/translation-implementation": ""
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1835,11 +1843,11 @@
"interoperability", "interoperability",
"standards" "standards"
], ],
"time": "2019-04-27T14:29:50+00:00" "time": "2019-05-28T07:50:59+00:00"
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
@ -1892,16 +1900,16 @@
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37" "reference": "22b4d033e6bb6d94a928545a3456007b8d0da907"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/2d279b6bb1d582dd5740d4d3251ae8c18812ed37", "url": "https://api.github.com/repos/symfony/debug/zipball/22b4d033e6bb6d94a928545a3456007b8d0da907",
"reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37", "reference": "22b4d033e6bb6d94a928545a3456007b8d0da907",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1944,11 +1952,11 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-04-11T11:27:41+00:00" "time": "2019-05-20T16:15:26+00:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v3.4.27", "version": "v3.4.28",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
@ -2011,16 +2019,16 @@
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
"reference": "e45135658bd6c14b61850bf131c4f09a55133f69" "reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/e45135658bd6c14b61850bf131c4f09a55133f69", "url": "https://api.github.com/repos/symfony/finder/zipball/e0ff582c4b038567a7c6630f136488b1d793e6a9",
"reference": "e45135658bd6c14b61850bf131c4f09a55133f69", "reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2056,20 +2064,20 @@
], ],
"description": "Symfony Finder Component", "description": "Symfony Finder Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-04-06T13:51:08+00:00" "time": "2019-05-26T20:47:34+00:00"
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718" "reference": "0d37a9bd2c7cbf887c29fee1a3301d74c73851dd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/1ea878bd3af18f934dedb8c0de60656a9a31a718", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0d37a9bd2c7cbf887c29fee1a3301d74c73851dd",
"reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718", "reference": "0d37a9bd2c7cbf887c29fee1a3301d74c73851dd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2110,7 +2118,7 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-05-01T08:36:31+00:00" "time": "2019-05-27T05:57:45+00:00"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
@ -2494,16 +2502,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "8cf39fb4ccff793340c258ee7760fd40bfe745fe" "reference": "57f11a07b34f009ef64a3f95ad218f895ad95374"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/8cf39fb4ccff793340c258ee7760fd40bfe745fe", "url": "https://api.github.com/repos/symfony/process/zipball/57f11a07b34f009ef64a3f95ad218f895ad95374",
"reference": "8cf39fb4ccff793340c258ee7760fd40bfe745fe", "reference": "57f11a07b34f009ef64a3f95ad218f895ad95374",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2539,20 +2547,20 @@
], ],
"description": "Symfony Process Component", "description": "Symfony Process Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-04-10T16:20:36+00:00" "time": "2019-05-26T20:47:34+00:00"
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab" "reference": "c5ce09ed9db079dded1017a2494dbf6820efd204"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", "url": "https://api.github.com/repos/symfony/routing/zipball/c5ce09ed9db079dded1017a2494dbf6820efd204",
"reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", "reference": "c5ce09ed9db079dded1017a2494dbf6820efd204",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2615,25 +2623,25 @@
"uri", "uri",
"url" "url"
], ],
"time": "2019-04-27T09:38:08+00:00" "time": "2019-05-20T16:15:26+00:00"
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
"reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b" "reference": "5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/181a426dd129cb496f12d7e7555f6d0b37a7615b", "url": "https://api.github.com/repos/symfony/translation/zipball/5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee",
"reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b", "reference": "5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",
"symfony/contracts": "^1.0.2", "symfony/contracts": "^1.1.1",
"symfony/polyfill-mbstring": "~1.0" "symfony/polyfill-mbstring": "~1.0"
}, },
"conflict": { "conflict": {
@ -2642,7 +2650,7 @@
"symfony/yaml": "<3.4" "symfony/yaml": "<3.4"
}, },
"provide": { "provide": {
"symfony/translation-contracts-implementation": "1.0" "symfony/translation-implementation": "1.0"
}, },
"require-dev": { "require-dev": {
"psr/log": "~1.0", "psr/log": "~1.0",
@ -2690,11 +2698,11 @@
], ],
"description": "Symfony Translation Component", "description": "Symfony Translation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2019-05-01T12:55:36+00:00" "time": "2019-05-28T09:07:12+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v4.2.8", "version": "v4.2.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
@ -3742,16 +3750,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "7.5.11", "version": "7.5.12",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "64cb33f5b520da490a7b13149d39b43cf3c890c6" "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/64cb33f5b520da490a7b13149d39b43cf3c890c6", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c",
"reference": "64cb33f5b520da490a7b13149d39b43cf3c890c6", "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3822,7 +3830,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2019-05-14T04:53:02+00:00" "time": "2019-05-28T11:59:40+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",

View File

@ -21,7 +21,7 @@
<div class="pure-u-1 pure-u-md-1"> <div class="pure-u-1 pure-u-md-1">
<div> <div>
<a href="{{ route('publish.workflow.review.index') }}" class="pure-button button-small"> <a href="{{ route('publish.workflow.editor.index') }}" class="pure-button button-small">
<i class="fa fa-chevron-left"></i> <i class="fa fa-chevron-left"></i>
<span>BACK</span> <span>BACK</span>
</a> </a>