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

UpdateJudgeServerStatus   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
c 1
b 0
f 1
dl 0
loc 50
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 19 3
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