Passed
Pull Request — master (#744)
by John
07:01
created

UpdateJudgeServerStatus::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Console\Commands\Scheduling;
4
5
use Illuminate\Console\Command;
6
use App\Models\Eloquent\JudgeServer;
7
use App\Models\Eloquent\OJ;
8
use App\Babel\Babel;
9
use Carbon;
10
use Exception;
11
12
class UpdateJudgeServerStatus extends Command
13
{
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature='scheduling:updateJudgeServerStatus';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description='Scheduling for JudgeServer status update';
27
28
    /**
29
     * Create a new command instance.
30
     *
31
     * @return void
32
     */
33
    public function __construct()
34
    {
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Execute the console command.
40
     *
41
     * @return mixed
42
     */
43
    public function handle()
44
    {
45
        $time=Carbon::now();
46
        $this->line("<fg=yellow>[$time] Processing:  </>Update JudgeServer Status");
47
48
        $platformIDs = JudgeServer::column('oid');
49
        $babel=new Babel();
50
        foreach ($platformIDs as $platform) {
51
            try{
52
                $babel->monitor([
53
                    "name" => OJ::findOrFail($platform)->ocode
54
                ]);
55
            } catch (Exception $e) {
56
                Log::alert("Moniting OID $platform Failed.\n".$e->getMessage());
0 ignored issues
show
Bug introduced by
The type App\Console\Commands\Scheduling\Log was not found. Did you mean Log? If so, make sure to prefix the type with \.
Loading history...
57
            }
58
        }
59
60
        $time=Carbon::now();
61
        $this->line("<fg=green>[$time] Processed:   </>Successfully Updated JudgeServer Status");
62
    }
63
}
64