From 390f6bbef838d702dfb8a0edb3780ff835693653 Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Wed, 29 May 2019 14:04:46 +0200 Subject: [PATCH] artisan cron job for automatically rejecting approved datasets --- app/Console/Commands/DatasetState.php | 66 ++++++++++ app/Console/Commands/Inspire.php | 49 ++++---- app/Console/Kernel.php | 58 ++++++--- .../Controllers/Publish/EditorController.php | 2 +- composer.lock | 116 ++++++++++-------- .../views/workflow/editor/reject.blade.php | 2 +- 6 files changed, 193 insertions(+), 100 deletions(-) create mode 100644 app/Console/Commands/DatasetState.php diff --git a/app/Console/Commands/DatasetState.php b/app/Console/Commands/DatasetState.php new file mode 100644 index 0000000..eca2cbf --- /dev/null +++ b/app/Console/Commands/DatasetState.php @@ -0,0 +1,66 @@ +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' + ]); + } + } +} diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php index b5b0c0d..d56a91c 100755 --- a/app/Console/Commands/Inspire.php +++ b/app/Console/Commands/Inspire.php @@ -1,32 +1,33 @@ -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); + } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 0c088c8..4d48bb1 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -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'); + } } diff --git a/app/Http/Controllers/Publish/EditorController.php b/app/Http/Controllers/Publish/EditorController.php index 7cc9f18..5ff6817 100644 --- a/app/Http/Controllers/Publish/EditorController.php +++ b/app/Http/Controllers/Publish/EditorController.php @@ -301,7 +301,7 @@ class EditorController extends Controller $input = $request->all(); $input['server_state'] = 'approved'; if ($dataset->reject_reviewer_note != null) { - $input['[reject_reviewer_note'] = null; + $input['reject_reviewer_note'] = null; } if ($dataset->update($input)) { diff --git a/composer.lock b/composer.lock index 6794f17..9be0f93 100755 --- a/composer.lock +++ b/composer.lock @@ -1696,16 +1696,16 @@ }, { "name": "symfony/console", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81" + "reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/e2840bb38bddad7a0feaf85931e38fdcffdb2f81", - "reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81", + "url": "https://api.github.com/repos/symfony/console/zipball/7a293c9a4587a92e6a0e81edb0bea54071b1b99d", + "reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d", "shasum": "" }, "require": { @@ -1764,25 +1764,32 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-04-08T14:23:48+00:00" + "time": "2019-05-09T09:19:46+00:00" }, { "name": "symfony/contracts", - "version": "v1.1.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/symfony/contracts.git", - "reference": "d3636025e8253c6144358ec0a62773cae588395b" + "reference": "b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/contracts/zipball/d3636025e8253c6144358ec0a62773cae588395b", - "reference": "d3636025e8253c6144358ec0a62773cae588395b", + "url": "https://api.github.com/repos/symfony/contracts/zipball/b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f", + "reference": "b6e291a08e6b002fb56aa6f3e2a2beb6674d2b2f", "shasum": "" }, "require": { "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": { "psr/cache": "^1.0", "psr/container": "^1.0", @@ -1791,11 +1798,12 @@ "suggest": { "psr/cache": "When using the Cache 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/http-client-contracts-implementation": "", - "symfony/service-contracts-implementation": "", - "symfony/translation-contracts-implementation": "" + "symfony/http-client-implementation": "", + "symfony/service-implementation": "", + "symfony/translation-implementation": "" }, "type": "library", "extra": { @@ -1835,11 +1843,11 @@ "interoperability", "standards" ], - "time": "2019-04-27T14:29:50+00:00" + "time": "2019-05-28T07:50:59+00:00" }, { "name": "symfony/css-selector", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -1892,16 +1900,16 @@ }, { "name": "symfony/debug", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37" + "reference": "22b4d033e6bb6d94a928545a3456007b8d0da907" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/2d279b6bb1d582dd5740d4d3251ae8c18812ed37", - "reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37", + "url": "https://api.github.com/repos/symfony/debug/zipball/22b4d033e6bb6d94a928545a3456007b8d0da907", + "reference": "22b4d033e6bb6d94a928545a3456007b8d0da907", "shasum": "" }, "require": { @@ -1944,11 +1952,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-04-11T11:27:41+00:00" + "time": "2019-05-20T16:15:26+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.4.27", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2011,16 +2019,16 @@ }, { "name": "symfony/finder", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "e45135658bd6c14b61850bf131c4f09a55133f69" + "reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/e45135658bd6c14b61850bf131c4f09a55133f69", - "reference": "e45135658bd6c14b61850bf131c4f09a55133f69", + "url": "https://api.github.com/repos/symfony/finder/zipball/e0ff582c4b038567a7c6630f136488b1d793e6a9", + "reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9", "shasum": "" }, "require": { @@ -2056,20 +2064,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-04-06T13:51:08+00:00" + "time": "2019-05-26T20:47:34+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718" + "reference": "0d37a9bd2c7cbf887c29fee1a3301d74c73851dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/1ea878bd3af18f934dedb8c0de60656a9a31a718", - "reference": "1ea878bd3af18f934dedb8c0de60656a9a31a718", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0d37a9bd2c7cbf887c29fee1a3301d74c73851dd", + "reference": "0d37a9bd2c7cbf887c29fee1a3301d74c73851dd", "shasum": "" }, "require": { @@ -2110,7 +2118,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-05-01T08:36:31+00:00" + "time": "2019-05-27T05:57:45+00:00" }, { "name": "symfony/http-kernel", @@ -2494,16 +2502,16 @@ }, { "name": "symfony/process", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8cf39fb4ccff793340c258ee7760fd40bfe745fe" + "reference": "57f11a07b34f009ef64a3f95ad218f895ad95374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8cf39fb4ccff793340c258ee7760fd40bfe745fe", - "reference": "8cf39fb4ccff793340c258ee7760fd40bfe745fe", + "url": "https://api.github.com/repos/symfony/process/zipball/57f11a07b34f009ef64a3f95ad218f895ad95374", + "reference": "57f11a07b34f009ef64a3f95ad218f895ad95374", "shasum": "" }, "require": { @@ -2539,20 +2547,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-04-10T16:20:36+00:00" + "time": "2019-05-26T20:47:34+00:00" }, { "name": "symfony/routing", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab" + "reference": "c5ce09ed9db079dded1017a2494dbf6820efd204" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", - "reference": "f4e43bb0dff56f0f62fa056c82d7eadcdb391bab", + "url": "https://api.github.com/repos/symfony/routing/zipball/c5ce09ed9db079dded1017a2494dbf6820efd204", + "reference": "c5ce09ed9db079dded1017a2494dbf6820efd204", "shasum": "" }, "require": { @@ -2615,25 +2623,25 @@ "uri", "url" ], - "time": "2019-04-27T09:38:08+00:00" + "time": "2019-05-20T16:15:26+00:00" }, { "name": "symfony/translation", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b" + "reference": "5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/181a426dd129cb496f12d7e7555f6d0b37a7615b", - "reference": "181a426dd129cb496f12d7e7555f6d0b37a7615b", + "url": "https://api.github.com/repos/symfony/translation/zipball/5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee", + "reference": "5fe4ec5ecc04fa43c34f8df033bf60e3729bfaee", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/contracts": "^1.0.2", + "symfony/contracts": "^1.1.1", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { @@ -2642,7 +2650,7 @@ "symfony/yaml": "<3.4" }, "provide": { - "symfony/translation-contracts-implementation": "1.0" + "symfony/translation-implementation": "1.0" }, "require-dev": { "psr/log": "~1.0", @@ -2690,11 +2698,11 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2019-05-01T12:55:36+00:00" + "time": "2019-05-28T09:07:12+00:00" }, { "name": "symfony/var-dumper", - "version": "v4.2.8", + "version": "v4.2.9", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", @@ -3742,16 +3750,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.5.11", + "version": "7.5.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "64cb33f5b520da490a7b13149d39b43cf3c890c6" + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/64cb33f5b520da490a7b13149d39b43cf3c890c6", - "reference": "64cb33f5b520da490a7b13149d39b43cf3c890c6", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", "shasum": "" }, "require": { @@ -3822,7 +3830,7 @@ "testing", "xunit" ], - "time": "2019-05-14T04:53:02+00:00" + "time": "2019-05-28T11:59:40+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/resources/views/workflow/editor/reject.blade.php b/resources/views/workflow/editor/reject.blade.php index ed3ad21..92279ac 100644 --- a/resources/views/workflow/editor/reject.blade.php +++ b/resources/views/workflow/editor/reject.blade.php @@ -21,7 +21,7 @@
- + BACK