@@ -19,6 +19,6 @@ |
||
19 | 19 | |
20 | 20 | public function contest() |
21 | 21 | { |
22 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
22 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
23 | 23 | } |
24 | 24 | } |
@@ -15,6 +15,6 @@ |
||
15 | 15 | |
16 | 16 | public function submissions() |
17 | 17 | { |
18 | - return $this->hasMany('App\Models\Eloquent\SubmissionModel','pid','pid'); |
|
18 | + return $this->hasMany('App\Models\Eloquent\SubmissionModel', 'pid', 'pid'); |
|
19 | 19 | } |
20 | 20 | } |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | const CREATED_AT=null; |
18 | 18 | |
19 | 19 | //Repository function |
20 | - public function participants($ignore_frozen = true) |
|
20 | + public function participants($ignore_frozen=true) |
|
21 | 21 | { |
22 | - if($this->registration){ |
|
23 | - $participants = ContestParticipant::where('cid',$this->cid)->get(); |
|
22 | + if ($this->registration) { |
|
23 | + $participants=ContestParticipant::where('cid', $this->cid)->get(); |
|
24 | 24 | $participants->load('user'); |
25 | - $users = new EloquentCollection; |
|
25 | + $users=new EloquentCollection; |
|
26 | 26 | foreach ($participants as $participant) { |
27 | - $user = $participant->user; |
|
27 | + $user=$participant->user; |
|
28 | 28 | $users->add($user); |
29 | 29 | } |
30 | 30 | return $users->unique(); |
31 | - }else{ |
|
31 | + } else { |
|
32 | 32 | $this->load('submissions.user'); |
33 | - if($ignore_frozen){ |
|
34 | - $frozen_time = $this->frozen_time; |
|
35 | - $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
|
36 | - }else{ |
|
37 | - $submissions = $this->submissions; |
|
33 | + if ($ignore_frozen) { |
|
34 | + $frozen_time=$this->frozen_time; |
|
35 | + $submissions=$this->submissions()->where('submission_date', '<', $frozen_time)->get(); |
|
36 | + } else { |
|
37 | + $submissions=$this->submissions; |
|
38 | 38 | } |
39 | - $users = new EloquentCollection; |
|
39 | + $users=new EloquentCollection; |
|
40 | 40 | foreach ($submissions as $submission) { |
41 | - $user = $submission->user; |
|
41 | + $user=$submission->user; |
|
42 | 42 | $users->add($user); |
43 | 43 | } |
44 | 44 | return $users->unique(); |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | // Repository/Service? function |
49 | 49 | public function rankRefresh() |
50 | 50 | { |
51 | - $ret = []; |
|
52 | - $participants = $this->participants(); |
|
53 | - $contest_problems = $this->problems; |
|
51 | + $ret=[]; |
|
52 | + $participants=$this->participants(); |
|
53 | + $contest_problems=$this->problems; |
|
54 | 54 | $contest_problems->load('problem'); |
55 | - if($this->rule == 1){ |
|
55 | + if ($this->rule==1) { |
|
56 | 56 | // ACM/ICPC Mode |
57 | 57 | foreach ($participants as $participant) { |
58 | 58 | $prob_detail=[]; |
59 | 59 | $totPen=0; |
60 | 60 | $totScore=0; |
61 | 61 | foreach ($contest_problems as $contest_problem) { |
62 | - $prob_stat = $contest_problem->userStatus($participant); |
|
62 | + $prob_stat=$contest_problem->userStatus($participant); |
|
63 | 63 | $prob_detail[]=[ |
64 | 64 | 'ncode'=>$contest_problem->ncode, |
65 | 65 | 'pid'=>$contest_problem->pid, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | "problem_detail" => $prob_detail |
86 | 86 | ]; |
87 | 87 | } |
88 | - usort($ret, function ($a, $b) { |
|
88 | + usort($ret, function($a, $b) { |
|
89 | 89 | if ($a["score"]==$b["score"]) { |
90 | 90 | if ($a["penalty"]==$b["penalty"]) { |
91 | 91 | return 0; |
@@ -102,31 +102,31 @@ discard block |
||
102 | 102 | }); |
103 | 103 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
104 | 104 | return $ret; |
105 | - }else{ |
|
105 | + } else { |
|
106 | 106 | // IO Mode |
107 | - $c = new OutdatedContestModel(); |
|
107 | + $c=new OutdatedContestModel(); |
|
108 | 108 | return $c->contestRankCache($this->cid); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | public function problems() |
113 | 113 | { |
114 | - return $this->hasMany('App\Models\Eloquent\ContestProblem','cid','cid'); |
|
114 | + return $this->hasMany('App\Models\Eloquent\ContestProblem', 'cid', 'cid'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function submissions() |
118 | 118 | { |
119 | - return $this->hasMany('App\Models\Eloquent\SubmissionModel','cid','cid'); |
|
119 | + return $this->hasMany('App\Models\Eloquent\SubmissionModel', 'cid', 'cid'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function group() |
123 | 123 | { |
124 | - return $this->hasOne('App\Models\Eloquent\GroupModel','gid','gid'); |
|
124 | + return $this->hasOne('App\Models\Eloquent\GroupModel', 'gid', 'gid'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function getFrozenTimeAttribute() |
128 | 128 | { |
129 | - $end_time = strtotime($this->end_time); |
|
130 | - return $end_time - $this->froze_length; |
|
129 | + $end_time=strtotime($this->end_time); |
|
130 | + return $end_time-$this->froze_length; |
|
131 | 131 | } |
132 | 132 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | $users->add($user); |
29 | 29 | } |
30 | 30 | return $users->unique(); |
31 | - }else{ |
|
31 | + } else{ |
|
32 | 32 | $this->load('submissions.user'); |
33 | 33 | if($ignore_frozen){ |
34 | 34 | $frozen_time = $this->frozen_time; |
35 | 35 | $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | $submissions = $this->submissions; |
38 | 38 | } |
39 | 39 | $users = new EloquentCollection; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | }); |
103 | 103 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
104 | 104 | return $ret; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | // IO Mode |
107 | 107 | $c = new OutdatedContestModel(); |
108 | 108 | return $c->contestRankCache($this->cid); |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | { |
9 | 9 | protected $table='contest_problem'; |
10 | 10 | protected $primaryKey='cpid'; |
11 | - public $timestamps = null; |
|
11 | + public $timestamps=null; |
|
12 | 12 | const DELETED_AT=null; |
13 | 13 | const UPDATED_AT=null; |
14 | 14 | const CREATED_AT=null; |
15 | 15 | |
16 | 16 | public function contest() |
17 | 17 | { |
18 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
18 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function problem() |
22 | 22 | { |
23 | - return $this->belongsTo('App\Models\Eloquent\ProblemModel','pid','pid'); |
|
23 | + return $this->belongsTo('App\Models\Eloquent\ProblemModel', 'pid', 'pid'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function submissions() |
27 | 27 | { |
28 | - return $this->problem->submissions()->where('cid',$this->contest->cid); |
|
28 | + return $this->problem->submissions()->where('cid', $this->contest->cid); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | //This should be a repository...or service function ? |
@@ -38,34 +38,34 @@ discard block |
||
38 | 38 | 'wrong_doings' => 0, |
39 | 39 | 'color' => '', |
40 | 40 | ]; |
41 | - $ac_record = $this->ac_record($user); |
|
42 | - if(!empty($ac_record[0])){ |
|
43 | - $ret['solved'] = 1; |
|
44 | - $ret['solved_time'] = $ac_record[0]->submission_date - strtotime($this->contest->begin_time); |
|
45 | - $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
|
46 | - $ret['wrong_doings'] = $ac_record[2]; |
|
47 | - $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
48 | - }else{ |
|
49 | - $ret['wrong_doings'] = $ac_record[2]; |
|
41 | + $ac_record=$this->ac_record($user); |
|
42 | + if (!empty($ac_record[0])) { |
|
43 | + $ret['solved']=1; |
|
44 | + $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time); |
|
45 | + $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']); |
|
46 | + $ret['wrong_doings']=$ac_record[2]; |
|
47 | + $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
48 | + } else { |
|
49 | + $ret['wrong_doings']=$ac_record[2]; |
|
50 | 50 | } |
51 | 51 | return $ret; |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function ac_record($user) |
55 | 55 | { |
56 | - $user_ac = $this->submissions()->where([ |
|
56 | + $user_ac=$this->submissions()->where([ |
|
57 | 57 | 'uid' => $user->id, |
58 | 58 | 'verdict' => 'Accepted' |
59 | 59 | ])->first(); |
60 | 60 | |
61 | - $other_ac = 1; |
|
62 | - $wrong_trys = 0; |
|
63 | - if(!empty($user_ac)){ |
|
64 | - $other_ac = $this->submissions() |
|
65 | - ->where('verdict','Accepted') |
|
61 | + $other_ac=1; |
|
62 | + $wrong_trys=0; |
|
63 | + if (!empty($user_ac)) { |
|
64 | + $other_ac=$this->submissions() |
|
65 | + ->where('verdict', 'Accepted') |
|
66 | 66 | ->where('submission_date', '<', $user_ac->submission_date) |
67 | 67 | ->count(); |
68 | - $wrong_trys = $this->submissions()->where([ |
|
68 | + $wrong_trys=$this->submissions()->where([ |
|
69 | 69 | 'uid' => $user->id, |
70 | 70 | ])->whereIn('verdict', [ |
71 | 71 | 'Runtime Error', |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | 'Presentation Error', |
77 | 77 | 'Output Limit Exceeded' |
78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
79 | - }else{ |
|
80 | - $wrong_trys = $this->submissions()->where([ |
|
79 | + } else { |
|
80 | + $wrong_trys=$this->submissions()->where([ |
|
81 | 81 | 'uid' => $user->id, |
82 | 82 | ])->whereIn('verdict', [ |
83 | 83 | 'Runtime Error', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
46 | 46 | $ret['wrong_doings'] = $ac_record[2]; |
47 | 47 | $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
48 | - }else{ |
|
48 | + } else{ |
|
49 | 49 | $ret['wrong_doings'] = $ac_record[2]; |
50 | 50 | } |
51 | 51 | return $ret; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'Presentation Error', |
77 | 77 | 'Output Limit Exceeded' |
78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
79 | - }else{ |
|
79 | + } else{ |
|
80 | 80 | $wrong_trys = $this->submissions()->where([ |
81 | 81 | 'uid' => $user->id, |
82 | 82 | ])->whereIn('verdict', [ |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function schedule(Schedule $schedule) |
36 | 36 | { |
37 | - $schedule->call(function () { |
|
37 | + $schedule->call(function() { |
|
38 | 38 | $babel=new Babel(); |
39 | 39 | for ($i=1; $i<=12; $i++) { |
40 | 40 | $babel->judge(); |
@@ -43,35 +43,35 @@ discard block |
||
43 | 43 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Judger"); |
44 | 44 | })->everyMinute()->description("Sync Judger"); |
45 | 45 | |
46 | - $schedule->call(function () { |
|
46 | + $schedule->call(function() { |
|
47 | 47 | $rankModel=new RankModel(); |
48 | 48 | $rankModel->rankList(); |
49 | 49 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated Rank"); |
50 | 50 | })->dailyAt('02:00')->description("Update Rank"); |
51 | 51 | |
52 | - $schedule->call(function () { |
|
52 | + $schedule->call(function() { |
|
53 | 53 | $siteMapModel=new SiteMapModel(); |
54 | 54 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated SiteMap"); |
55 | 55 | })->dailyAt('02:00')->description("Update SiteMap"); |
56 | 56 | |
57 | - $schedule->call(function () { |
|
57 | + $schedule->call(function() { |
|
58 | 58 | $groupModel=new GroupModel(); |
59 | 59 | $groupModel->cacheTrendingGroups(); |
60 | 60 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Cached Trending Groups"); |
61 | 61 | })->dailyAt('03:00')->description("Update Trending Groups"); |
62 | 62 | |
63 | 63 | $schedule->call(function() { |
64 | - $groupModel = new GroupModel(); |
|
65 | - $ret = $groupModel->refreshAllElo(); |
|
64 | + $groupModel=new GroupModel(); |
|
65 | + $ret=$groupModel->refreshAllElo(); |
|
66 | 66 | foreach ($ret as $gid => $group) { |
67 | - if(empty($group['result'])){ |
|
67 | + if (empty($group['result'])) { |
|
68 | 68 | Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']); |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']); |
71 | 71 | foreach ($group['result'] as $contest) { |
72 | - if($contest['ret'] == 'success'){ |
|
72 | + if ($contest['ret']=='success') { |
|
73 | 73 | Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']); |
74 | - }else{ |
|
74 | + } else { |
|
75 | 75 | Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:'); |
76 | 76 | foreach ($contest['submissions'] as $sid) { |
77 | 77 | Log::channel('group_elo')->info(' '.$sid['sid']); |
@@ -82,46 +82,46 @@ discard block |
||
82 | 82 | } |
83 | 83 | })->dailyAt('04:00')->description("Update Group Elo"); |
84 | 84 | |
85 | - $schedule->call(function () { |
|
86 | - $contestModel = new ContestModel(); |
|
87 | - $syncList = $contestModel->runningContest(); |
|
85 | + $schedule->call(function() { |
|
86 | + $contestModel=new ContestModel(); |
|
87 | + $syncList=$contestModel->runningContest(); |
|
88 | 88 | foreach ($syncList as $syncContest) { |
89 | 89 | if (!isset($syncContest['vcid'])) { |
90 | - $contest = EloquentContestModel::find($syncContest['cid']); |
|
91 | - $contestRankRaw = $contest->rankRefresh(); |
|
90 | + $contest=EloquentContestModel::find($syncContest['cid']); |
|
91 | + $contestRankRaw=$contest->rankRefresh(); |
|
92 | 92 | $cid=$syncContest['cid']; |
93 | 93 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
94 | 94 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
95 | - continue ; |
|
95 | + continue; |
|
96 | 96 | } |
97 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
98 | - $all_data = [ |
|
97 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
98 | + $all_data=[ |
|
99 | 99 | 'oj'=>"hdu", |
100 | 100 | 'vcid'=>$syncContest['vcid'], |
101 | 101 | 'gid'=>$syncContest['gid'], |
102 | 102 | 'cid'=>$syncContest['cid'], |
103 | 103 | ]; |
104 | - $hduSync = new $className($all_data); |
|
104 | + $hduSync=new $className($all_data); |
|
105 | 105 | $hduSync->crawlRank(); |
106 | 106 | $hduSync->crawlClarification(); |
107 | 107 | } |
108 | 108 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Remote Rank and Clarification"); |
109 | 109 | })->everyMinute()->description("Sync Remote Rank and Clarification"); |
110 | 110 | |
111 | - $schedule->call(function () { |
|
112 | - $contestModel = new ContestModel(); |
|
113 | - $syncList = $contestModel->runningContest(); |
|
111 | + $schedule->call(function() { |
|
112 | + $contestModel=new ContestModel(); |
|
113 | + $syncList=$contestModel->runningContest(); |
|
114 | 114 | foreach ($syncList as $syncContest) { |
115 | 115 | if (isset($syncContest['crawled'])) { |
116 | 116 | if (!$syncContest['crawled']) { |
117 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
118 | - $all_data = [ |
|
117 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
118 | + $all_data=[ |
|
119 | 119 | 'oj'=>"hdu", |
120 | 120 | 'vcid'=>$syncContest['vcid'], |
121 | 121 | 'gid'=>$syncContest['gid'], |
122 | 122 | 'cid'=>$syncContest['cid'], |
123 | 123 | ]; |
124 | - $hduSync = new $className($all_data); |
|
124 | + $hduSync=new $className($all_data); |
|
125 | 125 | $hduSync->scheduleCrawl(); |
126 | 126 | $contestModel->updateCrawlStatus($syncContest['cid']); |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | })->everyMinute()->description("Sync Contest Problem"); |
131 | 131 | |
132 | - $schedule->call(function () { |
|
132 | + $schedule->call(function() { |
|
133 | 133 | $oidList=EloquentJudgeServerModel::column('oid'); |
134 | 134 | $babel=new Babel(); |
135 | 135 | foreach ($oidList as $oid) { |