Completed
Push — master ( 4f00d5...2afce4 )
by John
29s queued 13s
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
use Log;
12
13
class UpdateJudgeServerStatus extends Command
14
{
15
    /**
16
     * The name and signature of the console command.
17
     *
18
     * @var string
19
     */
20
    protected $signature='scheduling:updateJudgeServerStatus';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description='Scheduling for JudgeServer status update';
28
29
    /**
30
     * Create a new command instance.
31
     *
32
     * @return void
33
     */
34
    public function __construct()
35
    {
36
        parent::__construct();
37
    }
38
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return mixed
43
     */
44
    public function handle()
45
    {
46
        $time=Carbon::now();
47
        $this->line("<fg=yellow>[$time] Processing:  </>Update JudgeServer Status");
48
49
        $platformIDs=JudgeServer::column('oid');
50
        $babel=new Babel();
51
        foreach ($platformIDs as $platform) {
52
            try {
53
                $babel->monitor([
54
                    "name" => OJ::findOrFail($platform)->ocode
55
                ]);
56
            } catch (Exception $e) {
57
                Log::alert("Moniting OID $platform Failed.\n".$e->getMessage());
58
            }
59
        }
60
61
        $time=Carbon::now();
62
        $this->line("<fg=green>[$time] Processed:   </>Successfully Updated JudgeServer Status");
63
    }
64
}
65