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

UpdateGroupElo   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 22
c 1
b 0
f 1
dl 0
loc 58
rs 10
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 27 6
1
<?php
2
3
namespace App\Console\Commands\Scheduling;
4
5
use Illuminate\Console\Command;
6
use App\Models\GroupModel;
7
use Carbon;
8
9
class UpdateGroupElo extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature='scheduling:updateGroupElo';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description='Scheduling for group elo update';
24
25
    /**
26
     * Create a new command instance.
27
     *
28
     * @return void
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        $time=Carbon::now();
43
        $this->line("<fg=yellow>[$time] Processing:  </>Update Group Elo");
44
45
        $groupModel=new GroupModel();
46
        $ret=$groupModel->refreshAllElo();
47
        foreach ($ret as $gid => $group) {
48
            if (empty($group['result'])) {
49
                Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']);
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...
50
            } else {
51
                Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']);
52
                foreach ($group['result'] as $contest) {
53
                    if ($contest['ret']=='success') {
54
                        Log::channel('group_elo')->info('    Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']);
55
                    } else {
56
                        Log::channel('group_elo')->info('    Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].'  sids:');
57
                        foreach ($contest['submissions'] as $sid) {
58
                            Log::channel('group_elo')->info('        '.$sid['sid']);
59
                        }
60
                    }
61
                }
62
            }
63
        }
64
65
        $time=Carbon::now();
66
        $this->line("<fg=green>[$time] Processed:   </>Successfully Updated Group Elo");
67
    }
68
}
69