Kernel.php 1.45 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1
2
3
4
<?php

namespace App\Console;

5
use DB;
Dominik Hebeler's avatar
Dominik Hebeler committed
6
7
8
9
10
11
12
13
14
15
16
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
17

Dominik Hebeler's avatar
Dominik Hebeler committed
18
19
20
21
22
23
24
25
26
27
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
28
29
30
31
        $schedule->command('requests:gather')->everyFifteenMinutes();

        $schedule->call(function () {
            DB::table('monthlyrequests')->truncate();
Dominik Hebeler's avatar
Dominik Hebeler committed
32
            DB::disconnect('mysql');
33
        })->monthlyOn(1, '00:00');
34
35

        // Delete all of the old humanverification entries
36
        $schedule->call(function () {
37
38
            DB::delete('DELETE FROM humanverification WHERE updated_at < (now() - interval 72 hour) AND whitelist = 0 ORDER BY updated_at DESC');
            DB::delete('DELETE FROM humanverification WHERE updated_at < (now() - interval 2 week) AND whitelist = 1 ORDER BY updated_at DESC');
Dominik Hebeler's avatar
Dominik Hebeler committed
39
            DB::disconnect('mysql');
40
        })->everyThirtyMinutes();
41
42
43
44
45
46
47
48
49
50
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
51
        $this->load(__DIR__ . '/Commands');
Dominik Hebeler's avatar
Dominik Hebeler committed
52
53
    }
}