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

SyncRankClarification::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 30
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 23
c 1
b 0
f 1
nc 3
nop 0
dl 0
loc 30
rs 9.552
1
<?php
2
3
namespace App\Console\Commands\Scheduling;
4
5
use Illuminate\Console\Command;
6
use App\Models\ContestModel;
7
use Carbon;
8
9
class SyncRankClarification extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature='scheduling:syncRankClarification';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description='Scheduling for remote rank and clarification sync';
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:  </>Sync Remote Contest Rank and Clarification");
44
45
        $contestModel=new ContestModel();
46
        $syncList=$contestModel->runningContest();
47
        foreach ($syncList as $syncContest) {
48
            if (!isset($syncContest['vcid'])) {
49
                $contest=Contest::find($syncContest['cid']);
0 ignored issues
show
Bug introduced by
The type App\Console\Commands\Scheduling\Contest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
                $contestRankRaw=$contest->rankRefresh();
51
                $cid=$syncContest['cid'];
52
                Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
0 ignored issues
show
Bug introduced by
The type App\Console\Commands\Scheduling\Cache was not found. Did you mean Cache? If so, make sure to prefix the type with \.
Loading history...
53
                Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
54
                continue;
55
            }
56
            $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement.
57
            $all_data=[
58
                'oj'=>"hdu",
59
                'vcid'=>$syncContest['vcid'],
60
                'gid'=>$syncContest['gid'],
61
                'cid'=>$syncContest['cid'],
62
            ];
63
            $hduSync=new $className($all_data);
64
            $hduSync->crawlRank();
65
            $hduSync->crawlClarification();
66
        }
67
68
        $time=Carbon::now();
69
        $this->line("<fg=green>[$time] Processed:   </>Successfully Synced Remote Contest Rank and Clarification");
70
    }
71
}
72