Passed
Pull Request — master (#343)
by
unknown
04:45
created
app/Http/Controllers/Contest/BoardController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         $contestModel=new ContestModel();
35 35
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
36 36
         $basicInfo=$contestModel->basic($cid);
37
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
38
-            if($clearance == 3){
37
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
38
+            if ($clearance==3) {
39 39
                 return Redirect::route('contest.admin', ['cid' => $cid]);
40
-            }else{
40
+            } else {
41 41
                 return Redirect::route('contest.detail', ['cid' => $cid]);
42 42
             }
43 43
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if ($remainingTime<=0) {
51 51
             $remainingTime=0;
52 52
         }
53
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
53
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
54 54
             return Redirect::route('contest.detail', ['cid' => $cid]);
55 55
         }
56 56
         return view('contest.board.challenge', [
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
         $accountModel=new AccountModel();
84 84
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
85 85
         $basicInfo=$contestModel->basic($cid);
86
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
87
-            if($clearance == 3){
86
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
87
+            if ($clearance==3) {
88 88
                 return Redirect::route('contest.admin', ['cid' => $cid]);
89
-            }else{
89
+            } else {
90 90
                 return Redirect::route('contest.detail', ['cid' => $cid]);
91 91
             }
92 92
         }
93 93
         $basicInfo=$contestModel->basic($cid);
94
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
94
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
95 95
             return Redirect::route('contest.detail', ['cid' => $cid]);
96 96
         }
97 97
         $contest_name=$contestModel->contestName($cid);
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
             ];
123 123
         }
124 124
 
125
-        $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
-        if(empty($editor_left_width)) $editor_left_width='40';
125
+        $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
+        if (empty($editor_left_width)) $editor_left_width='40';
127 127
 
128 128
         return view('contest.board.editor', [
129 129
             'page_title'=>"Problem Detail",
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
         $contestModel=new ContestModel();
158 158
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
159 159
         $basicInfo=$contestModel->basic($cid);
160
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
161
-            if($clearance == 3){
160
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
161
+            if ($clearance==3) {
162 162
                 return Redirect::route('contest.admin', ['cid' => $cid]);
163
-            }else{
163
+            } else {
164 164
                 return Redirect::route('contest.detail', ['cid' => $cid]);
165 165
             }
166 166
         }
167 167
         $basicInfo=$contestModel->basic($cid);
168
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
168
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
169 169
             return Redirect::route('contest.detail', ['cid' => $cid]);
170 170
         }
171 171
         $contest_name=$contestModel->contestName($cid);
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 
177 177
         // To determine the ranking
178 178
         foreach ($contestRank as $i => &$r) {
179
-            if($i != 0) {
180
-                if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){
181
-                    $r['rank'] = $contestRank[$i-1]['rank'];
182
-                }else{
183
-                    $r['rank'] = $i + 1;
179
+            if ($i!=0) {
180
+                if ($r['score']==$contestRank[$i-1]['score'] && ($contest_rule==1 ? ($r['penalty']==$contestRank[$i-1]['penalty']) : 1)) {
181
+                    $r['rank']=$contestRank[$i-1]['rank'];
182
+                } else {
183
+                    $r['rank']=$i+1;
184 184
                 }
185
-            }else{
186
-                $r['rank'] = 1;
185
+            } else {
186
+                $r['rank']=1;
187 187
             }
188 188
         }
189 189
         $rankFrozen=$contestModel->isFrozen($cid);
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
         $contestModel=new ContestModel();
221 221
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
222 222
         $basicInfo=$contestModel->basic($cid);
223
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
224
-            if($clearance == 3){
223
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
224
+            if ($clearance==3) {
225 225
                 return Redirect::route('contest.admin', ['cid' => $cid]);
226
-            }else{
226
+            } else {
227 227
                 return Redirect::route('contest.detail', ['cid' => $cid]);
228 228
             }
229 229
         }
230 230
         $basicInfo=$contestModel->basic($cid);
231
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
231
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
232 232
             return Redirect::route('contest.detail', ['cid' => $cid]);
233 233
         }
234 234
         $contest_name=$contestModel->contestName($cid);
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
         $contestModel=new ContestModel();
263 263
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
264 264
         $basicInfo=$contestModel->basic($cid);
265
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
266
-            if($clearance == 3){
265
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
266
+            if ($clearance==3) {
267 267
                 return Redirect::route('contest.admin', ['cid' => $cid]);
268
-            }else{
268
+            } else {
269 269
                 return Redirect::route('contest.detail', ['cid' => $cid]);
270 270
             }
271 271
         }
272
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
272
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
273 273
             return Redirect::route('contest.detail', ['cid' => $cid]);
274 274
         }
275 275
         $contest_name=$contestModel->contestName($cid);
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
         $contestModel=new ContestModel();
301 301
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
302 302
         $basicInfo=$contestModel->basic($cid);
303
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
304
-            if($clearance == 3){
303
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
304
+            if ($clearance==3) {
305 305
                 return Redirect::route('contest.admin', ['cid' => $cid]);
306
-            }else{
306
+            } else {
307 307
                 return Redirect::route('contest.detail', ['cid' => $cid]);
308 308
             }
309 309
         }
310
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
310
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
311 311
             return Redirect::route('contest.detail', ['cid' => $cid]);
312 312
         }
313 313
         $contest_name=$contestModel->contestName($cid);
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
         ]);
325 325
     }
326 326
 
327
-    public function analysis($cid){
327
+    public function analysis($cid) {
328 328
         $contestModel=new ContestModel();
329 329
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
330 330
         $basicInfo=$contestModel->basic($cid);
331
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
332
-            if($clearance == 3){
331
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
332
+            if ($clearance==3) {
333 333
                 return Redirect::route('contest.admin', ['cid' => $cid]);
334
-            }else{
334
+            } else {
335 335
                 return Redirect::route('contest.detail', ['cid' => $cid]);
336 336
             }
337 337
         }
338 338
         $basicInfo=$contestModel->basic($cid);
339
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
339
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
340 340
             return Redirect::route('contest.detail', ['cid' => $cid]);
341 341
         }
342 342
         $contest_name=$contestModel->contestName($cid);
Please login to merge, or discard this patch.
app/Models/Submission/SubmissionModel.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
                                             ->where(['verdict'=>'Waiting'])
372 372
                                             ->get()
373 373
                                             ->all();
374
-        foreach($ret as &$r){
374
+        foreach ($ret as &$r) {
375 375
             $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"];
376 376
         }
377 377
         return $ret;
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
         if (isset($sub['verdict'])) {
390 390
             $sub["color"]=$this->colorScheme[$sub['verdict']];
391 391
         }
392
-        $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
393
-        $contestModel = new ContestModel();
394
-        $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
395
-        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){
396
-            $sub['pid'] = $submission_info['pid'];
397
-            $sub['uid'] = $submission_info['uid'];
398
-            $sub['cid'] = $submission_info['cid'];
399
-            $sub['sid'] = $sid;
392
+        $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub);
393
+        $contestModel=new ContestModel();
394
+        $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first();
395
+        if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) {
396
+            $sub['pid']=$submission_info['pid'];
397
+            $sub['uid']=$submission_info['uid'];
398
+            $sub['cid']=$submission_info['cid'];
399
+            $sub['sid']=$sid;
400 400
             // $contestModel->updateContestRankTable($submission_info['cid'],$sub);
401 401
         }
402 402
         return $result;
@@ -468,15 +468,15 @@  discard block
 block discarded – undo
468 468
             'desc'
469 469
         );
470 470
 
471
-        if($filter["pcode"]){
471
+        if ($filter["pcode"]) {
472 472
             $paginator=$paginator->where(["pcode"=>$filter["pcode"]]);
473 473
         }
474 474
 
475
-        if($filter["result"]){
475
+        if ($filter["result"]) {
476 476
             $paginator=$paginator->where(["verdict"=>$filter["result"]]);
477 477
         }
478 478
 
479
-        if($filter["account"]){
479
+        if ($filter["account"]) {
480 480
             $paginator=$paginator->where(["name"=>$filter["account"]]);
481 481
         }
482 482
 
Please login to merge, or discard this patch.
app/Models/ContestModel.php 1 patch
Spacing   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function gcode($cid)
115 115
     {
116
-        $gid = $this->gid($cid);
117
-        return DB::table('group')->where('gid','=',$gid)->first()["gcode"];
116
+        $gid=$this->gid($cid);
117
+        return DB::table('group')->where('gid', '=', $gid)->first()["gcode"];
118 118
     }
119 119
 
120 120
     public function runningContest()
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
 
140 140
     public function listForSetting($gid)
141 141
     {
142
-        $uid = Auth::user()->id;
143
-        $group_contests = DB::table('contest')
144
-            ->where('gid',$gid)
145
-            ->orderBy('begin_time','desc')
142
+        $uid=Auth::user()->id;
143
+        $group_contests=DB::table('contest')
144
+            ->where('gid', $gid)
145
+            ->orderBy('begin_time', 'desc')
146 146
             ->get()->all();
147
-        $groupModel = new GroupModel();
148
-        $group_clearance = $groupModel->judgeClearance($gid,$uid);
147
+        $groupModel=new GroupModel();
148
+        $group_clearance=$groupModel->judgeClearance($gid, $uid);
149 149
         foreach ($group_contests as &$contest) {
150
-            $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3);
151
-            $contest['begin_stamps'] = strtotime($contest['begin_time']);
152
-            $contest['end_stamps'] = strtotime($contest['end_time']);
153
-            $contest['status'] = time() >= $contest['end_stamps'] ? 1
154
-                : (time() <= $contest['begin_stamps'] ? -1 : 0);
150
+            $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3);
151
+            $contest['begin_stamps']=strtotime($contest['begin_time']);
152
+            $contest['end_stamps']=strtotime($contest['end_time']);
153
+            $contest['status']=time()>=$contest['end_stamps'] ? 1
154
+                : (time()<=$contest['begin_stamps'] ? -1 : 0);
155 155
             $contest["rule_parsed"]=$this->rule[$contest["rule"]];
156 156
             $contest["date_parsed"]=[
157 157
                 "date"=>date_format(date_create($contest["begin_time"]), 'j'),
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
             ];
160 160
             $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]);
161 161
         }
162
-        usort($group_contests,function($a,$b){
163
-            if($a['is_admin'] == $b['is_admin']){
164
-                return $b['begin_stamps'] - $a['begin_stamps'];
162
+        usort($group_contests, function($a, $b) {
163
+            if ($a['is_admin']==$b['is_admin']) {
164
+                return $b['begin_stamps']-$a['begin_stamps'];
165 165
             }
166
-            return $b['is_admin'] - $a['is_admin'];
166
+            return $b['is_admin']-$a['is_admin'];
167 167
         });
168 168
         return $group_contests;
169 169
     }
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
         //     "gid"=>$gid
175 175
         // ])->orderBy('begin_time', 'desc')->get()->all();
176 176
         $preQuery=DB::table($this->tableName);
177
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
177
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
178 178
         $contest_list=$paginator->all();
179
-        if(empty($contest_list)){
179
+        if (empty($contest_list)) {
180 180
             return null;
181 181
         }
182 182
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         ])->first()["rule"];
202 202
     }
203 203
 
204
-    public function list($filter,$uid)
204
+    public function list($filter, $uid)
205 205
     {
206 206
         if ($uid) {
207 207
             //$paginator=DB::select('SELECT DISTINCT contest.* FROM group_member inner join contest on group_member.gid=contest.gid left join contest_participant on contest.cid=contest_participant.cid where (public=1 and audit=1) or (group_member.uid=:uid and group_member.role>0 and (contest_participant.uid=:uidd or ISNULL(contest_participant.uid)) and (registration=0 or (registration=1 and not ISNULL(contest_participant.uid))))',["uid"=>$uid,"uidd"=>$uid])->paginate(10);
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
                 if ($filter['practice']) {
226 226
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
227 227
                 }
228
-                $paginator = $paginator ->paginate(10);
229
-            }elseif($filter['public']=='0'){
228
+                $paginator=$paginator ->paginate(10);
229
+            }elseif ($filter['public']=='0') {
230 230
                 $paginator=DB::table('group_member')
231 231
                 ->groupBy('contest.cid')
232 232
                 ->select('contest.*')
233 233
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
234 234
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
235 235
                 ->where(
236
-                    function ($query) use ($filter,$uid) {
236
+                    function($query) use ($filter, $uid) {
237 237
                         if ($filter['rule']) {
238 238
                             $query=$query->where(["rule"=>$filter['rule']]);
239 239
                         }
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
                 )
257 257
                 ->orderBy('contest.begin_time', 'desc')
258 258
                 ->paginate(10);
259
-            }else{
259
+            } else {
260 260
                 $paginator=DB::table('group_member')
261 261
                 ->groupBy('contest.cid')
262 262
                 ->select('contest.*')
263 263
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
264 264
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
265 265
                 ->where(
266
-                    function ($query) use ($filter) {
266
+                    function($query) use ($filter) {
267 267
                         if ($filter['rule']) {
268 268
                             $query=$query->where(["rule"=>$filter['rule']]);
269 269
                         }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                     }
285 285
                 )
286 286
                 ->orWhere(
287
-                    function ($query) use ($filter,$uid) {
287
+                    function($query) use ($filter, $uid) {
288 288
                         if ($filter['rule']) {
289 289
                             $query=$query->where(["rule"=>$filter['rule']]);
290 290
                         }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             if ($filter['practice']) {
331 331
                 $paginator=$paginator->where(["practice"=>$filter['practice']]);
332 332
             }
333
-            $paginator = $paginator ->paginate(10);
333
+            $paginator=$paginator ->paginate(10);
334 334
         }
335 335
         $contest_list=$paginator->all();
336 336
         foreach ($contest_list as &$c) {
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
         }
369 369
     }
370 370
 
371
-    public function registContest($cid,$uid)
371
+    public function registContest($cid, $uid)
372 372
     {
373 373
         $registered=DB::table("contest_participant")->where([
374 374
             "cid"=>$cid,
375 375
             "uid"=>$uid
376 376
         ])->first();
377 377
 
378
-        if(empty($registered)){
378
+        if (empty($registered)) {
379 379
             DB::table("contest_participant")->insert([
380 380
                 "cid"=>$cid,
381 381
                 "uid"=>$uid,
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             ]);
384 384
             $name=User::find($uid)->name;
385 385
             $contest=$this->basic($cid);
386
-            $url=route('contest.detail',['cid' => $cid]);
386
+            $url=route('contest.detail', ['cid' => $cid]);
387 387
             sendMessage([
388 388
                 'receiver' => $uid,
389 389
                 'sender' => 1, // potential bugs
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
     public function problems($cid)
418 418
     {
419 419
         return DB::table('contest_problem')
420
-            ->join('problem','contest_problem.pid','=','problem.pid')
421
-            ->where('cid',$cid)
422
-            ->select('problem.pid as pid','pcode','number')
420
+            ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
421
+            ->where('cid', $cid)
422
+            ->select('problem.pid as pid', 'pcode', 'number')
423 423
             ->orderBy('number')
424 424
             ->get()->all();
425 425
     }
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
442 442
 
443 443
         foreach ($problemSet as &$p) {
444
-            if($p['practice']){
445
-                $tags = DB::table("group_problem_tag")
446
-                ->where('gid',$p['gid'])
447
-                ->where('pid',$p['pid'])
444
+            if ($p['practice']) {
445
+                $tags=DB::table("group_problem_tag")
446
+                ->where('gid', $p['gid'])
447
+                ->where('pid', $p['pid'])
448 448
                 ->get()->all();
449
-                $tags_arr = [];
450
-                if(!empty($tags)){
449
+                $tags_arr=[];
450
+                if (!empty($tags)) {
451 451
                     foreach ($tags as $value) {
452
-                        array_push($tags_arr,$value['tag']);
452
+                        array_push($tags_arr, $value['tag']);
453 453
                     }
454 454
                 }
455
-                $p['tags'] = $tags_arr;
455
+                $p['tags']=$tags_arr;
456 456
             }
457 457
             if ($contest_rule==1) {
458 458
                 $prob_stat=DB::table("submission")->select(
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                     "problem_detail" => $prob_detail
714 714
                 ];
715 715
             }
716
-            usort($ret, function ($a, $b) {
716
+            usort($ret, function($a, $b) {
717 717
                 if ($a["score"]==$b["score"]) {
718 718
                     if ($a["penalty"]==$b["penalty"]) {
719 719
                         return 0;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
                     "problem_detail" => $prob_detail
761 761
                 ];
762 762
             }
763
-            usort($ret, function ($a, $b) {
763
+            usort($ret, function($a, $b) {
764 764
                 if ($a["score"]==$b["score"]) {
765 765
                     if ($a["solved"]==$b["solved"]) {
766 766
                         return 0;
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         return $ret;
783 783
     }
784 784
 
785
-    public function contestRank($cid, $uid = 0)
785
+    public function contestRank($cid, $uid=0)
786 786
     {
787 787
         // [ToDo] If the current user's in the organizer group show nick name
788 788
         // [ToDo] The participants determination
@@ -800,35 +800,35 @@  discard block
 block discarded – undo
800 800
             "gid" => $contest_info["gid"]
801 801
         ])->where("role", ">", 0)->first());
802 802
 
803
-        $clearance = $this -> judgeClearance($cid, $uid);
803
+        $clearance=$this -> judgeClearance($cid, $uid);
804 804
 
805 805
         /** New Version With MySQL */
806 806
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
807 807
 
808
-        if(time() < $end_time){
809
-            if($clearance == 3){
808
+        if (time()<$end_time) {
809
+            if ($clearance==3) {
810 810
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
811
-            }else{
811
+            } else {
812 812
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
813 813
             }
814
-            if(!isset($contestRankRaw)){
814
+            if (!isset($contestRankRaw)) {
815 815
                 $contestRankRaw=$this->contestRankCache($cid);
816 816
             }
817
-        }else{
818
-            if($clearance == 3){
817
+        } else {
818
+            if ($clearance==3) {
819 819
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
820 820
                 if (!isset($contestRankRaw)) {
821 821
                     $contestRankRaw=$this->getContestRankFromMySQL($cid);
822
-                    if(!isset($contestRankRaw)){
822
+                    if (!isset($contestRankRaw)) {
823 823
                         $contestRankRaw=$this->contestRankCache($cid);
824 824
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
825 825
                     }
826 826
                 }
827
-            }else{
827
+            } else {
828 828
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
829
-                if(!isset($contestRankRaw)){
829
+                if (!isset($contestRankRaw)) {
830 830
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
831
-                    if(!isset($contestRankRaw)){
831
+                    if (!isset($contestRankRaw)) {
832 832
                         $contestRankRaw=$this->contestRankCache($cid);
833 833
                     }
834 834
                     $this->storeContestRankInMySQL($cid, $contestRankRaw);
@@ -846,15 +846,15 @@  discard block
 block discarded – undo
846 846
         //         $contestRankRaw=$this->contestRankCache($cid);
847 847
         //     }
848 848
         // }
849
-        if($contest_info["rule"]==1){
849
+        if ($contest_info["rule"]==1) {
850 850
             foreach ($contestRankRaw as &$cr) {
851
-                $solved = 0;
852
-                foreach($cr['problem_detail'] as $pd){
853
-                    if(!empty($pd['solved_time_parsed'])){
854
-                        $solved ++;
851
+                $solved=0;
852
+                foreach ($cr['problem_detail'] as $pd) {
853
+                    if (!empty($pd['solved_time_parsed'])) {
854
+                        $solved++;
855 855
                     }
856 856
                 }
857
-                $cr['solved'] = $solved;
857
+                $cr['solved']=$solved;
858 858
             }
859 859
         }
860 860
 
@@ -903,16 +903,16 @@  discard block
 block discarded – undo
903 903
 
904 904
     public function getClarificationList($cid)
905 905
     {
906
-        $uid = Auth::user()->id;
907
-        $clearance = $this -> judgeClearance($cid, $uid);
908
-        if($clearance == 3){
906
+        $uid=Auth::user()->id;
907
+        $clearance=$this -> judgeClearance($cid, $uid);
908
+        if ($clearance==3) {
909 909
             return DB::table("contest_clarification")->where([
910 910
                 "cid"=>$cid
911 911
             ])->orderBy('create_time', 'desc')->get()->all();
912
-        }else{
912
+        } else {
913 913
             return DB::table("contest_clarification")->where([
914 914
                 "cid"=>$cid
915
-            ])->where(function ($query) {
915
+            ])->where(function($query) {
916 916
                 $query->where([
917 917
                     "public"=>1
918 918
                 ])->orWhere([
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
     public function getContestRecord($filter, $cid)
1059 1059
     {
1060 1060
         $basicInfo=$this->basic($cid);
1061
-        $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first();
1061
+        $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first();
1062 1062
         $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
1063 1063
             "cid"=>$cid
1064 1064
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
@@ -1071,14 +1071,14 @@  discard block
 block discarded – undo
1071 1071
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1072 1072
         $contestEnd=time()>$end_time;
1073 1073
 
1074
-        $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1075
-        if($filter['pid']==false){
1076
-            $filter['pid'] = null;
1077
-        }else{
1078
-            $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1074
+        $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1075
+        if ($filter['pid']==false) {
1076
+            $filter['pid']=null;
1077
+        } else {
1078
+            $filter['pid']=$problemSet_temp[$filter['pid']]['pid'];
1079 1079
         }
1080 1080
 
1081
-        if($userInfo==null || $userInfo["role"]!=3){
1081
+        if ($userInfo==null || $userInfo["role"]!=3) {
1082 1082
             if ($basicInfo["status_visibility"]==2) {
1083 1083
                 // View all
1084 1084
                 $paginator=DB::table("submission")->where([
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
                     "users.id",
1093 1093
                     "=",
1094 1094
                     "submission.uid"
1095
-                )->where(function ($query) use ($frozen_time) {
1095
+                )->where(function($query) use ($frozen_time) {
1096 1096
                     $query->where(
1097 1097
                         "submission_date",
1098 1098
                         "<",
@@ -1119,15 +1119,15 @@  discard block
 block discarded – undo
1119 1119
                     'desc'
1120 1120
                 );
1121 1121
 
1122
-                if($filter["pid"]){
1122
+                if ($filter["pid"]) {
1123 1123
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1124 1124
                 }
1125 1125
 
1126
-                if($filter["result"]){
1126
+                if ($filter["result"]) {
1127 1127
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1128 1128
                 }
1129 1129
 
1130
-                if($filter["account"]){
1130
+                if ($filter["account"]) {
1131 1131
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1132 1132
                 }
1133 1133
 
@@ -1163,15 +1163,15 @@  discard block
 block discarded – undo
1163 1163
                     'desc'
1164 1164
                 );
1165 1165
 
1166
-                if($filter["pid"]){
1166
+                if ($filter["pid"]) {
1167 1167
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1168 1168
                 }
1169 1169
 
1170
-                if($filter["result"]){
1170
+                if ($filter["result"]) {
1171 1171
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1172 1172
                 }
1173 1173
 
1174
-                if($filter["account"]){
1174
+                if ($filter["account"]) {
1175 1175
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1176 1176
                 }
1177 1177
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
                     "records"=>[]
1183 1183
                 ];
1184 1184
             }
1185
-        }else{
1185
+        } else {
1186 1186
             if ($basicInfo["status_visibility"]==2) {
1187 1187
                 // View all
1188 1188
                 $paginator=DB::table("submission")->where([
@@ -1214,15 +1214,15 @@  discard block
 block discarded – undo
1214 1214
                     'desc'
1215 1215
                 );
1216 1216
 
1217
-                if($filter["pid"]){
1217
+                if ($filter["pid"]) {
1218 1218
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1219 1219
                 }
1220 1220
 
1221
-                if($filter["result"]){
1221
+                if ($filter["result"]) {
1222 1222
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1223 1223
                 }
1224 1224
 
1225
-                if($filter["account"]){
1225
+                if ($filter["account"]) {
1226 1226
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1227 1227
                 }
1228 1228
 
@@ -1258,15 +1258,15 @@  discard block
 block discarded – undo
1258 1258
                     'desc'
1259 1259
                 );
1260 1260
 
1261
-                if($filter["pid"]){
1261
+                if ($filter["pid"]) {
1262 1262
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1263 1263
                 }
1264 1264
 
1265
-                if($filter["result"]){
1265
+                if ($filter["result"]) {
1266 1266
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1267 1267
                 }
1268 1268
 
1269
-                if($filter["account"]){
1269
+                if ($filter["account"]) {
1270 1270
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1271 1271
                 }
1272 1272
 
@@ -1322,21 +1322,21 @@  discard block
 block discarded – undo
1322 1322
         if ($uid==0) {
1323 1323
             return 0;
1324 1324
         }
1325
-        $groupModel = new GroupModel();
1325
+        $groupModel=new GroupModel();
1326 1326
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
1327
-        $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first();
1327
+        $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first();
1328 1328
 
1329
-        if(empty($contest_info)){
1329
+        if (empty($contest_info)) {
1330 1330
             // contest not exist
1331 1331
             return 0;
1332 1332
         }
1333 1333
 
1334
-        if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){
1334
+        if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) {
1335 1335
             return 3;
1336 1336
         }
1337 1337
 
1338
-        $contest_started = strtotime($contest_info['begin_time']) < time();
1339
-        $contest_ended = strtotime($contest_info['end_time']) < time();
1338
+        $contest_started=strtotime($contest_info['begin_time'])<time();
1339
+        $contest_ended=strtotime($contest_info['end_time'])<time();
1340 1340
         if (!$contest_started) {
1341 1341
             // not started or do not exist
1342 1342
             return 0;
@@ -1427,12 +1427,12 @@  discard block
 block discarded – undo
1427 1427
     public function updateProfessionalRate($cid)
1428 1428
     {
1429 1429
         $basic=$this->basic($cid);
1430
-        if($basic["rated"]&&!$basic["is_rated"]){
1430
+        if ($basic["rated"] && !$basic["is_rated"]) {
1431 1431
             $ratingCalculator=new RatingCalculator($cid);
1432
-            if($ratingCalculator->calculate()){
1432
+            if ($ratingCalculator->calculate()) {
1433 1433
                 $ratingCalculator->storage();
1434 1434
                 return true;
1435
-            }else{
1435
+            } else {
1436 1436
                 return false;
1437 1437
             }
1438 1438
         } else {
@@ -1440,26 +1440,26 @@  discard block
 block discarded – undo
1440 1440
         }
1441 1441
     }
1442 1442
 
1443
-    public function contestUpdate($cid,$data,$problems)
1443
+    public function contestUpdate($cid, $data, $problems)
1444 1444
     {
1445
-        if($problems !== false){
1446
-            $old_problmes = array_column(
1445
+        if ($problems!==false) {
1446
+            $old_problmes=array_column(
1447 1447
                 DB::table('contest_problem')
1448
-                ->where('cid',$cid)
1448
+                ->where('cid', $cid)
1449 1449
                 ->get()->all(),
1450 1450
                 'pid'
1451 1451
             );
1452
-            DB::transaction(function () use ($cid, $data, $problems,$old_problmes) {
1452
+            DB::transaction(function() use ($cid, $data, $problems, $old_problmes) {
1453 1453
                 DB::table($this->tableName)
1454
-                    ->where('cid',$cid)
1454
+                    ->where('cid', $cid)
1455 1455
                     ->update($data);
1456 1456
                 DB::table('contest_problem')
1457
-                    ->where('cid',$cid)
1457
+                    ->where('cid', $cid)
1458 1458
                     ->delete();
1459
-                $new_problems = [];
1459
+                $new_problems=[];
1460 1460
                 foreach ($problems as $p) {
1461 1461
                     $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"];
1462
-                    array_push($new_problems,$pid);
1462
+                    array_push($new_problems, $pid);
1463 1463
                     DB::table("contest_problem")->insert([
1464 1464
                         "cid"=>$cid,
1465 1465
                         "number"=>$p["number"],
@@ -1469,29 +1469,29 @@  discard block
 block discarded – undo
1469 1469
                         "points"=>$p["points"]
1470 1470
                     ]);
1471 1471
                 }
1472
-                foreach($old_problmes as $op) {
1473
-                    if(!in_array($op,$new_problems)){
1472
+                foreach ($old_problmes as $op) {
1473
+                    if (!in_array($op, $new_problems)) {
1474 1474
                         DB::table('submission')
1475
-                            ->where('cid',$cid)
1476
-                            ->where('pid',$op)
1475
+                            ->where('cid', $cid)
1476
+                            ->where('pid', $op)
1477 1477
                             ->delete();
1478 1478
                     }
1479 1479
                 }
1480 1480
             }, 5);
1481
-            $contestRankRaw = $this->contestRankCache($cid);
1481
+            $contestRankRaw=$this->contestRankCache($cid);
1482 1482
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1483 1483
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1484
-        }else{
1484
+        } else {
1485 1485
             DB::table($this->tableName)
1486
-                ->where('cid',$cid)
1486
+                ->where('cid', $cid)
1487 1487
                 ->update($data);
1488 1488
         }
1489 1489
     }
1490 1490
 
1491
-    public function contestUpdateProblem($cid,$problems)
1491
+    public function contestUpdateProblem($cid, $problems)
1492 1492
     {
1493 1493
         DB::table('contest_problem')
1494
-                ->where('cid',$cid)
1494
+                ->where('cid', $cid)
1495 1495
                 ->delete();
1496 1496
         foreach ($problems as $p) {
1497 1497
             DB::table("contest_problem")->insertGetId([
@@ -1507,8 +1507,8 @@  discard block
 block discarded – undo
1507 1507
 
1508 1508
     public function arrangeContest($gid, $config, $problems)
1509 1509
     {
1510
-        $cid = -1;
1511
-        DB::transaction(function () use ($gid, $config, $problems,&$cid) {
1510
+        $cid=-1;
1511
+        DB::transaction(function() use ($gid, $config, $problems, &$cid) {
1512 1512
             $cid=DB::table($this->tableName)->insertGetId([
1513 1513
                 "gid"=>$gid,
1514 1514
                 "name"=>$config["name"],
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
                 "rule"=>1, //todo
1523 1523
                 "begin_time"=>$config["begin_time"],
1524 1524
                 "end_time"=>$config["end_time"],
1525
-                "vcid"=>isset($config["vcid"])?$config["vcid"]:null,
1525
+                "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null,
1526 1526
                 "public"=>$config["public"],
1527 1527
                 "registration"=>0, //todo
1528 1528
                 "registration_due"=>null, //todo
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
                 "froze_length"=>0, //todo
1531 1531
                 "status_visibility"=>2, //todo
1532 1532
                 "create_time"=>date("Y-m-d H:i:s"),
1533
-                "crawled" => isset($config['vcid'])?$config['crawled'] : null,
1533
+                "crawled" => isset($config['vcid']) ? $config['crawled'] : null,
1534 1534
                 "audit_status"=>$config["public"] ? 0 : 1
1535 1535
             ]);
1536 1536
 
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
         return $cid;
1550 1550
     }
1551 1551
 
1552
-    public function updateContestRankTable($cid,$sub)
1552
+    public function updateContestRankTable($cid, $sub)
1553 1553
     {
1554
-        $lock = Cache::lock("contestrank$cid",10);
1555
-        try{
1556
-            if($lock->get()){
1557
-                if(Cache::tags(['contest','rank'])->get($cid) != null){
1558
-                    $ret = Cache::tags(['contest','rank'])->get($cid);
1554
+        $lock=Cache::lock("contestrank$cid", 10);
1555
+        try {
1556
+            if ($lock->get()) {
1557
+                if (Cache::tags(['contest', 'rank'])->get($cid)!=null) {
1558
+                    $ret=Cache::tags(['contest', 'rank'])->get($cid);
1559 1559
                     $chache=[];
1560 1560
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
1561 1561
                     $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
@@ -1564,27 +1564,27 @@  discard block
 block discarded – undo
1564 1564
                     $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"];
1565 1565
                     $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1566 1566
 
1567
-                    $id = 0;
1567
+                    $id=0;
1568 1568
 
1569
-                    foreach($chache['problemSet'] as $key => $p){
1570
-                        if ($p['pid'] == $sub['pid']){
1571
-                            $chache['problemSet'][$key]['cpid'] = $key;
1572
-                            $id = $key;
1569
+                    foreach ($chache['problemSet'] as $key => $p) {
1570
+                        if ($p['pid']==$sub['pid']) {
1571
+                            $chache['problemSet'][$key]['cpid']=$key;
1572
+                            $id=$key;
1573 1573
                         }
1574 1574
                     }
1575 1575
 
1576
-                    $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret);
1577
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1576
+                    $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret);
1577
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1578 1578
 
1579
-                    if (time() < $chache['frozen_time']){
1579
+                    if (time()<$chache['frozen_time']) {
1580 1580
                         Cache::tags(['contest', 'rank'])->put($cid, $ret);
1581 1581
                     }
1582 1582
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret);
1583
-                    if(time() > $chache['end_time']){
1583
+                    if (time()>$chache['end_time']) {
1584 1584
                         $this->storeContestRankInMySQL($cid, $ret);
1585 1585
                     }
1586 1586
                 }
1587
-                else{
1587
+                else {
1588 1588
                     $ret=[];
1589 1589
                     $chache=[];
1590 1590
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
                             "cid"=>$cid,
1600 1600
                             "audit"=>1
1601 1601
                         ])->select('uid')->get()->all();
1602
-                    }else{
1602
+                    } else {
1603 1603
                         $submissionUsers=DB::table("submission")->where([
1604 1604
                             "cid"=>$cid
1605 1605
                         ])->where(
@@ -1612,39 +1612,39 @@  discard block
 block discarded – undo
1612 1612
                         ])->select('uid')->groupBy('uid')->get()->all();
1613 1613
                     }
1614 1614
 
1615
-                    $chacheAdmin = $chache;
1615
+                    $chacheAdmin=$chache;
1616 1616
 
1617 1617
                     foreach ($submissionUsers as $s) {
1618 1618
                         foreach ($chache['problemSet'] as $key => $p) {
1619
-                            $p['cpid'] = $key;
1620
-                            $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret);
1619
+                            $p['cpid']=$key;
1620
+                            $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret);
1621 1621
                         }
1622 1622
                     }
1623
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1623
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1624 1624
                     Cache::tags(['contest', 'rank'])->put($cid, $ret);
1625 1625
 
1626 1626
                     $retAdmin=[];
1627 1627
                     foreach ($submissionUsersAdmin as $s) {
1628 1628
                         foreach ($chacheAdmin['problemSet'] as $key => $p) {
1629
-                            $p['cpid'] = $key;
1630
-                            $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin);
1629
+                            $p['cpid']=$key;
1630
+                            $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin);
1631 1631
                         }
1632 1632
                     }
1633
-                    $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin);
1633
+                    $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin);
1634 1634
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1635 1635
                 }
1636 1636
             }
1637
-        }catch(LockTimeoutException $e){
1637
+        } catch (LockTimeoutException $e) {
1638 1638
             Log::warning("Contest Rank Lock Timed Out");
1639
-        }finally{
1639
+        } finally {
1640 1640
             optional($lock)->release();
1641 1641
         }
1642 1642
     }
1643 1643
 
1644
-    public function sortContestRankTable($contest_info,$cid,$ret)
1644
+    public function sortContestRankTable($contest_info, $cid, $ret)
1645 1645
     {
1646
-        if ($contest_info["rule"]==1){
1647
-            usort($ret, function ($a, $b) {
1646
+        if ($contest_info["rule"]==1) {
1647
+            usort($ret, function($a, $b) {
1648 1648
                 if ($a["score"]==$b["score"]) {
1649 1649
                     if ($a["penalty"]==$b["penalty"]) {
1650 1650
                         return 0;
@@ -1659,8 +1659,8 @@  discard block
 block discarded – undo
1659 1659
                     return 1;
1660 1660
                 }
1661 1661
             });
1662
-        }else if ($contest_info["rule"]==2){
1663
-            usort($ret, function ($a, $b) {
1662
+        } else if ($contest_info["rule"]==2) {
1663
+            usort($ret, function($a, $b) {
1664 1664
                 if ($a["score"]==$b["score"]) {
1665 1665
                     if ($a["solved"]==$b["solved"]) {
1666 1666
                         return 0;
@@ -1679,21 +1679,21 @@  discard block
 block discarded – undo
1679 1679
         return $ret;
1680 1680
     }
1681 1681
 
1682
-    public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret)
1682
+    public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret)
1683 1683
     {
1684
-        $id = count($ret);
1685
-        foreach($ret as $key => $r){
1686
-            if($r['uid'] == $uid)
1687
-                $id = $key;
1684
+        $id=count($ret);
1685
+        foreach ($ret as $key => $r) {
1686
+            if ($r['uid']==$uid)
1687
+                $id=$key;
1688 1688
         }
1689 1689
         if ($contest_info["rule"]==1) {
1690 1690
             // ACM/ICPC Mode
1691
-            if($id == count($ret)){
1692
-                $prob_detail = [];
1693
-                $totPen = 0;
1694
-                $totScore = 0;
1695
-            }else{
1696
-                $prob_detail = $ret[$id]['problem_detail'];
1691
+            if ($id==count($ret)) {
1692
+                $prob_detail=[];
1693
+                $totPen=0;
1694
+                $totScore=0;
1695
+            } else {
1696
+                $prob_detail=$ret[$id]['problem_detail'];
1697 1697
                 $totPen=$ret[$id]['penalty'];
1698 1698
                 $totScore=$ret[$id]['score'];
1699 1699
             };
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
                 "uid"=>$uid,
1712 1712
             ])->orderBy('submission_date', 'desc')->first();
1713 1713
 
1714
-            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){
1714
+            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") {
1715 1715
                 $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid);
1716 1716
 
1717 1717
                 $prob_detail[$problem['cpid']]=[
@@ -1743,12 +1743,12 @@  discard block
 block discarded – undo
1743 1743
             }
1744 1744
         } elseif ($contest_info["rule"]==2) {
1745 1745
             // IOI Mode
1746
-            if($id == count($ret)){
1747
-                $prob_detail = [];
1748
-                $totSolved = 0;
1749
-                $totScore = 0;
1750
-            }else{
1751
-                $prob_detail = $ret[$id]['problem_detail'];
1746
+            if ($id==count($ret)) {
1747
+                $prob_detail=[];
1748
+                $totSolved=0;
1749
+                $totScore=0;
1750
+            } else {
1751
+                $prob_detail=$ret[$id]['problem_detail'];
1752 1752
                 $totSolved=$ret[$id]['solved'];
1753 1753
                 $totScore=$ret[$id]['score'];
1754 1754
             };
@@ -1781,47 +1781,47 @@  discard block
 block discarded – undo
1781 1781
         return $ret;
1782 1782
     }
1783 1783
 
1784
-    public function assignMember($cid,$uid){
1784
+    public function assignMember($cid, $uid) {
1785 1785
         return DB::table("contest")->where(["cid"=>$cid])->update([
1786 1786
             "assign_uid"=>$uid
1787 1787
         ]);
1788 1788
     }
1789 1789
 
1790
-    public function canUpdateContestTime($cid,$time = [])
1790
+    public function canUpdateContestTime($cid, $time=[])
1791 1791
     {
1792
-        $begin_time_new = $time['begin'] ?? null;
1793
-        $end_time_new = $time['end'] ?? null;
1792
+        $begin_time_new=$time['begin'] ?? null;
1793
+        $end_time_new=$time['end'] ?? null;
1794 1794
 
1795
-        $hold_time = DB::table('contest')
1796
-            ->where('cid',$cid)
1797
-            ->select('begin_time','end_time')
1795
+        $hold_time=DB::table('contest')
1796
+            ->where('cid', $cid)
1797
+            ->select('begin_time', 'end_time')
1798 1798
             ->first();
1799
-        $begin_stamps = strtotime($hold_time['begin_time']);
1800
-        $end_stamps = strtotime($hold_time['end_time']);
1799
+        $begin_stamps=strtotime($hold_time['begin_time']);
1800
+        $end_stamps=strtotime($hold_time['end_time']);
1801 1801
         /*
1802 1802
         -1 : have not begun
1803 1803
          0 : ing
1804 1804
          1 : end
1805 1805
         */
1806
-        $status = time() >= $end_stamps ? 1
1807
-                : (time() <= $begin_stamps ? -1 : 0);
1808
-        if($status === -1){
1809
-            if(time() > $begin_time_new){
1806
+        $status=time()>=$end_stamps ? 1
1807
+                : (time()<=$begin_stamps ? -1 : 0);
1808
+        if ($status===-1) {
1809
+            if (time()>$begin_time_new) {
1810 1810
                 return false;
1811 1811
             }
1812 1812
             return true;
1813
-        }else if($status === 0){
1814
-            if($begin_time_new !== null){
1813
+        } else if ($status===0) {
1814
+            if ($begin_time_new!==null) {
1815 1815
                 return false;
1816 1816
             }
1817
-            if($end_time_new !== null){
1818
-                if(strtotime($end_time_new) <= time()){
1817
+            if ($end_time_new!==null) {
1818
+                if (strtotime($end_time_new)<=time()) {
1819 1819
                     return false;
1820
-                }else{
1820
+                } else {
1821 1821
                     return true;
1822 1822
                 }
1823 1823
             }
1824
-        }else{
1824
+        } else {
1825 1825
             return false;
1826 1826
         }
1827 1827
 
@@ -1830,22 +1830,22 @@  discard block
 block discarded – undo
1830 1830
 
1831 1831
     public function replyClarification($ccid, $content)
1832 1832
     {
1833
-        return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1833
+        return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1834 1834
             "reply"=>$content
1835 1835
         ]);
1836 1836
     }
1837 1837
 
1838 1838
     public function setClarificationPublic($ccid, $public)
1839 1839
     {
1840
-        if($public)
1840
+        if ($public)
1841 1841
         {
1842
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1842
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1843 1843
                 "public"=>1
1844 1844
             ]);
1845 1845
         }
1846 1846
         else
1847 1847
         {
1848
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1848
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1849 1849
                 "public"=>0
1850 1850
             ]);
1851 1851
         }
@@ -1858,90 +1858,90 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
     public function praticeAnalysis($cid)
1860 1860
     {
1861
-        $gid = DB::table('contest')
1862
-            ->where('cid',$cid)
1861
+        $gid=DB::table('contest')
1862
+            ->where('cid', $cid)
1863 1863
             ->first()['gid'];
1864
-        $contestRank = $this->contestRank($cid,Auth::user()->id);
1865
-        if(!empty($contestRank)){
1866
-            $all_problems = DB::table('problem')
1867
-            ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1868
-            ->select('pid','title')
1864
+        $contestRank=$this->contestRank($cid, Auth::user()->id);
1865
+        if (!empty($contestRank)) {
1866
+            $all_problems=DB::table('problem')
1867
+            ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid'))
1868
+            ->select('pid', 'title')
1869 1869
             ->get()->all();
1870
-        }else{
1871
-            $all_problems = [];
1870
+        } else {
1871
+            $all_problems=[];
1872 1872
         }
1873
-        $tags = DB::table('group_problem_tag')
1873
+        $tags=DB::table('group_problem_tag')
1874 1874
             ->where('gid', $gid)
1875
-            ->whereIn('pid', array_column($all_problems,'pid'))
1875
+            ->whereIn('pid', array_column($all_problems, 'pid'))
1876 1876
             ->get()->all();
1877
-        $all_tags = array_unique(array_column($tags,'tag'));
1878
-        $memberData = [];
1879
-        foreach($contestRank as $member){
1880
-            $m = [
1877
+        $all_tags=array_unique(array_column($tags, 'tag'));
1878
+        $memberData=[];
1879
+        foreach ($contestRank as $member) {
1880
+            $m=[
1881 1881
                 'uid' => $member['uid'],
1882 1882
                 'name' => $member['name'],
1883 1883
                 'nick_name' => $member['nick_name'],
1884 1884
             ];
1885
-            $completion = [];
1886
-            foreach ($all_tags as $tag){
1887
-                $completion[$tag] = [];
1885
+            $completion=[];
1886
+            foreach ($all_tags as $tag) {
1887
+                $completion[$tag]=[];
1888 1888
                 foreach ($tags as $t) {
1889
-                    if($t['tag'] == $tag){
1889
+                    if ($t['tag']==$tag) {
1890 1890
                         foreach ($member['problem_detail'] as $pd) {
1891
-                            if($pd['pid'] == $t['pid']){
1892
-                                $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1;
1891
+                            if ($pd['pid']==$t['pid']) {
1892
+                                $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1;
1893 1893
                             }
1894 1894
                         }
1895 1895
                     }
1896 1896
                 }
1897 1897
             }
1898
-            $m['completion'] = $completion;
1899
-            $memberData[] = $m;
1898
+            $m['completion']=$completion;
1899
+            $memberData[]=$m;
1900 1900
         }
1901 1901
         return $memberData;
1902 1902
     }
1903 1903
 
1904 1904
     public function storeContestRankInMySQL($cid, $data)
1905 1905
     {
1906
-        $contestRankJson = json_encode($data);
1907
-        return DB::table('contest')->where('cid','=',$cid)->update([
1906
+        $contestRankJson=json_encode($data);
1907
+        return DB::table('contest')->where('cid', '=', $cid)->update([
1908 1908
             'rank' => $contestRankJson
1909 1909
         ]);
1910 1910
     }
1911 1911
 
1912 1912
     public function getContestRankFromMySQL($cid)
1913 1913
     {
1914
-        $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first();
1915
-        $data = json_decode($contestRankJson, true);
1914
+        $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first();
1915
+        $data=json_decode($contestRankJson, true);
1916 1916
         return $data;
1917 1917
     }
1918 1918
 
1919 1919
     public function isVerified($cid)
1920 1920
     {
1921
-        return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first();
1921
+        return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first();
1922 1922
     }
1923 1923
 
1924 1924
     public function getScrollBoardData($cid)
1925 1925
     {
1926
-        $members = DB::table("submission")
1927
-            ->join('users','users.id','=','submission.uid')
1926
+        $members=DB::table("submission")
1927
+            ->join('users', 'users.id', '=', 'submission.uid')
1928 1928
             ->join('contest', 'contest.cid', '=', 'submission.cid')
1929 1929
             ->join('group_member', 'users.id', '=', 'group_member.uid')
1930
-            ->where('submission.cid', $cid)->select('users.id as uid','users.name as name','group_member.nick_name as nick_name')
1930
+            ->where('submission.cid', $cid)->select('users.id as uid', 'users.name as name', 'group_member.nick_name as nick_name')
1931 1931
             ->groupBy('uid')->get()->all();
1932
-        $submissions = DB::table("submission")
1932
+        $submissions=DB::table("submission")
1933 1933
             ->where('cid', $cid)
1934 1934
             ->select('sid', 'verdict', 'submission_date', 'pid', 'uid')
1935 1935
             ->orderBy('submission_date')
1936 1936
             ->get()->all();
1937
-        $problems = DB::table('contest_problem')
1937
+        $problems=DB::table('contest_problem')
1938 1938
             ->where('cid', $cid)
1939
-            ->select('ncode','pid')
1939
+            ->select('ncode', 'pid')
1940 1940
             ->orderBy('ncode')
1941 1941
             ->get()->all();
1942
-        $contest = DB::table('contest')
1943
-            ->where('cid',$cid)
1944
-            ->select('begin_time','end_time','froze_length')
1942
+        $contest=DB::table('contest')
1943
+            ->where('cid', $cid)
1944
+            ->select('begin_time', 'end_time', 'froze_length')
1945 1945
             ->first();
1946 1946
         return [
1947 1947
             'members' => $members,
@@ -1953,16 +1953,16 @@  discard block
 block discarded – undo
1953 1953
 
1954 1954
     public function judgeOver($cid)
1955 1955
     {
1956
-        $submissions =  DB::table('submission')
1956
+        $submissions=DB::table('submission')
1957 1957
             ->where(['cid' => $cid])
1958
-            ->whereIn('verdict',['Waiting','Pending'])
1958
+            ->whereIn('verdict', ['Waiting', 'Pending'])
1959 1959
             ->select('sid')
1960 1960
             ->get()->all();
1961
-        if(empty($submissions)){
1961
+        if (empty($submissions)) {
1962 1962
             return [
1963 1963
                 'result' => true
1964 1964
             ];
1965
-        }else{
1965
+        } else {
1966 1966
             return [
1967 1967
                 'result' => false,
1968 1968
                 'sid' => $submissions
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestParticipant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,6 +19,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ProblemModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestModel.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,28 +17,28 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestProblem.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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',
Please login to merge, or discard this patch.
app/Console/Kernel.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.