Completed
Push — master ( 4f00d5...2afce4 )
by John
29s queued 13s
created

SyncContestProblem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 26 4
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 SyncContestProblem extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature='scheduling:syncContestProblem';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description='Scheduling for remote contest problem 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 Problem");
44
45
        $contestModel=new ContestModel();
46
        $syncList=$contestModel->runningContest();
47
        foreach ($syncList as $syncContest) {
48
            if (isset($syncContest['crawled'])) {
49
                if (!$syncContest['crawled']) {
50
                    $className="App\\Babel\\Extension\\hdu\\Synchronizer";
51
                    $all_data=[
52
                        'oj'=>"hdu",
53
                        'vcid'=>$syncContest['vcid'],
54
                        'gid'=>$syncContest['gid'],
55
                        'cid'=>$syncContest['cid'],
56
                    ];
57
                    $hduSync=new $className($all_data);
58
                    $hduSync->scheduleCrawl();
59
                    $contestModel->updateCrawlStatus($syncContest['cid']);
60
                }
61
            }
62
        }
63
64
        $time=Carbon::now();
65
        $this->line("<fg=green>[$time] Processed:   </>Successfully Synced Remote Contest Problem");
66
    }
67
}
68