@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | |
113 | 113 | public function gcode($cid) |
114 | 114 | { |
115 | - $gid = $this->gid($cid); |
|
116 | - return DB::table('group')->where('gid','=',$gid)->first()["gcode"]; |
|
115 | + $gid=$this->gid($cid); |
|
116 | + return DB::table('group')->where('gid', '=', $gid)->first()["gcode"]; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | public function runningContest() |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | |
139 | 139 | public function listForSetting($gid) |
140 | 140 | { |
141 | - $uid = Auth::user()->id; |
|
142 | - $group_contests = DB::table('contest') |
|
143 | - ->where('gid',$gid) |
|
144 | - ->orderBy('begin_time','desc') |
|
141 | + $uid=Auth::user()->id; |
|
142 | + $group_contests=DB::table('contest') |
|
143 | + ->where('gid', $gid) |
|
144 | + ->orderBy('begin_time', 'desc') |
|
145 | 145 | ->get()->all(); |
146 | - $groupModel = new GroupModel(); |
|
147 | - $group_clearance = $groupModel->judgeClearance($gid,$uid); |
|
146 | + $groupModel=new GroupModel(); |
|
147 | + $group_clearance=$groupModel->judgeClearance($gid, $uid); |
|
148 | 148 | foreach ($group_contests as &$contest) { |
149 | - $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3); |
|
150 | - $contest['begin_stamps'] = strtotime($contest['begin_time']); |
|
151 | - $contest['end_stamps'] = strtotime($contest['end_time']); |
|
152 | - $contest['status'] = time() >= $contest['end_stamps'] ? 1 |
|
153 | - : (time() <= $contest['begin_stamps'] ? -1 : 0); |
|
149 | + $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3); |
|
150 | + $contest['begin_stamps']=strtotime($contest['begin_time']); |
|
151 | + $contest['end_stamps']=strtotime($contest['end_time']); |
|
152 | + $contest['status']=time()>=$contest['end_stamps'] ? 1 |
|
153 | + : (time()<=$contest['begin_stamps'] ? -1 : 0); |
|
154 | 154 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
155 | 155 | $contest["date_parsed"]=[ |
156 | 156 | "date"=>date_format(date_create($contest["begin_time"]), 'j'), |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | ]; |
159 | 159 | $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]); |
160 | 160 | } |
161 | - usort($group_contests,function($a,$b){ |
|
162 | - if($a['is_admin'] == $b['is_admin']){ |
|
163 | - return $b['begin_stamps'] - $a['begin_stamps']; |
|
161 | + usort($group_contests, function($a, $b) { |
|
162 | + if ($a['is_admin']==$b['is_admin']) { |
|
163 | + return $b['begin_stamps']-$a['begin_stamps']; |
|
164 | 164 | } |
165 | - return $b['is_admin'] - $a['is_admin']; |
|
165 | + return $b['is_admin']-$a['is_admin']; |
|
166 | 166 | }); |
167 | 167 | return $group_contests; |
168 | 168 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | // "gid"=>$gid |
174 | 174 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
175 | 175 | $preQuery=DB::table($this->tableName); |
176 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
176 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
177 | 177 | $contest_list=$paginator->all(); |
178 | - if(empty($contest_list)){ |
|
178 | + if (empty($contest_list)) { |
|
179 | 179 | return null; |
180 | 180 | } |
181 | 181 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ])->first()["rule"]; |
201 | 201 | } |
202 | 202 | |
203 | - public function list($filter,$uid) |
|
203 | + public function list($filter, $uid) |
|
204 | 204 | { |
205 | 205 | if ($uid) { |
206 | 206 | //$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); |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | if ($filter['practice']) { |
225 | 225 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
226 | 226 | } |
227 | - $paginator = $paginator ->paginate(10); |
|
228 | - }elseif($filter['public']=='0'){ |
|
227 | + $paginator=$paginator ->paginate(10); |
|
228 | + }elseif ($filter['public']=='0') { |
|
229 | 229 | $paginator=DB::table('group_member') |
230 | 230 | ->groupBy('contest.cid') |
231 | 231 | ->select('contest.*') |
232 | 232 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
233 | 233 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
234 | 234 | ->where( |
235 | - function ($query) use ($filter,$uid) { |
|
235 | + function($query) use ($filter, $uid) { |
|
236 | 236 | if ($filter['rule']) { |
237 | 237 | $query=$query->where(["rule"=>$filter['rule']]); |
238 | 238 | } |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | ) |
256 | 256 | ->orderBy('contest.begin_time', 'desc') |
257 | 257 | ->paginate(10); |
258 | - }else{ |
|
258 | + } else { |
|
259 | 259 | $paginator=DB::table('group_member') |
260 | 260 | ->groupBy('contest.cid') |
261 | 261 | ->select('contest.*') |
262 | 262 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
263 | 263 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
264 | 264 | ->where( |
265 | - function ($query) use ($filter) { |
|
265 | + function($query) use ($filter) { |
|
266 | 266 | if ($filter['rule']) { |
267 | 267 | $query=$query->where(["rule"=>$filter['rule']]); |
268 | 268 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | ) |
285 | 285 | ->orWhere( |
286 | - function ($query) use ($filter,$uid) { |
|
286 | + function($query) use ($filter, $uid) { |
|
287 | 287 | if ($filter['rule']) { |
288 | 288 | $query=$query->where(["rule"=>$filter['rule']]); |
289 | 289 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ($filter['practice']) { |
330 | 330 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
331 | 331 | } |
332 | - $paginator = $paginator ->paginate(10); |
|
332 | + $paginator=$paginator ->paginate(10); |
|
333 | 333 | } |
334 | 334 | $contest_list=$paginator->all(); |
335 | 335 | foreach ($contest_list as &$c) { |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | - public function registContest($cid,$uid) |
|
370 | + public function registContest($cid, $uid) |
|
371 | 371 | { |
372 | 372 | $registered=DB::table("contest_participant")->where([ |
373 | 373 | "cid"=>$cid, |
374 | 374 | "uid"=>$uid |
375 | 375 | ])->first(); |
376 | 376 | |
377 | - if(empty($registered)){ |
|
377 | + if (empty($registered)) { |
|
378 | 378 | DB::table("contest_participant")->insert([ |
379 | 379 | "cid"=>$cid, |
380 | 380 | "uid"=>$uid, |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | public function problems($cid) |
408 | 408 | { |
409 | 409 | return DB::table('contest_problem') |
410 | - ->join('problem','contest_problem.pid','=','problem.pid') |
|
411 | - ->where('cid',$cid) |
|
412 | - ->select('problem.pid as pid','pcode','number') |
|
410 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
411 | + ->where('cid', $cid) |
|
412 | + ->select('problem.pid as pid', 'pcode', 'number') |
|
413 | 413 | ->orderBy('number') |
414 | 414 | ->get()->all(); |
415 | 415 | } |
@@ -431,18 +431,18 @@ discard block |
||
431 | 431 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
432 | 432 | |
433 | 433 | foreach ($problemSet as &$p) { |
434 | - if($p['practice']){ |
|
435 | - $tags = DB::table("group_problem_tag") |
|
436 | - ->where('gid',$p['gid']) |
|
437 | - ->where('pid',$p['pid']) |
|
434 | + if ($p['practice']) { |
|
435 | + $tags=DB::table("group_problem_tag") |
|
436 | + ->where('gid', $p['gid']) |
|
437 | + ->where('pid', $p['pid']) |
|
438 | 438 | ->get()->all(); |
439 | - $tags_arr = []; |
|
440 | - if(!empty($tags)){ |
|
439 | + $tags_arr=[]; |
|
440 | + if (!empty($tags)) { |
|
441 | 441 | foreach ($tags as $value) { |
442 | - array_push($tags_arr,$value['tag']); |
|
442 | + array_push($tags_arr, $value['tag']); |
|
443 | 443 | } |
444 | 444 | } |
445 | - $p['tags'] = $tags_arr; |
|
445 | + $p['tags']=$tags_arr; |
|
446 | 446 | } |
447 | 447 | if ($contest_rule==1) { |
448 | 448 | $prob_stat=DB::table("submission")->select( |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | "problem_detail" => $prob_detail |
704 | 704 | ]; |
705 | 705 | } |
706 | - usort($ret, function ($a, $b) { |
|
706 | + usort($ret, function($a, $b) { |
|
707 | 707 | if ($a["score"]==$b["score"]) { |
708 | 708 | if ($a["penalty"]==$b["penalty"]) { |
709 | 709 | return 0; |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | "problem_detail" => $prob_detail |
751 | 751 | ]; |
752 | 752 | } |
753 | - usort($ret, function ($a, $b) { |
|
753 | + usort($ret, function($a, $b) { |
|
754 | 754 | if ($a["score"]==$b["score"]) { |
755 | 755 | if ($a["solved"]==$b["solved"]) { |
756 | 756 | return 0; |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | return $ret; |
773 | 773 | } |
774 | 774 | |
775 | - public function contestRank($cid, $uid = 0) |
|
775 | + public function contestRank($cid, $uid=0) |
|
776 | 776 | { |
777 | 777 | // [ToDo] If the current user's in the organizer group show nick name |
778 | 778 | // [ToDo] The participants determination |
@@ -790,35 +790,35 @@ discard block |
||
790 | 790 | "gid" => $contest_info["gid"] |
791 | 791 | ])->where("role", ">", 0)->first()); |
792 | 792 | |
793 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
793 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
794 | 794 | |
795 | 795 | /** New Version With MySQL */ |
796 | 796 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
797 | 797 | |
798 | - if(time() < $end_time){ |
|
799 | - if($clearance == 3){ |
|
798 | + if (time()<$end_time) { |
|
799 | + if ($clearance==3) { |
|
800 | 800 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
801 | - }else{ |
|
801 | + } else { |
|
802 | 802 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
803 | 803 | } |
804 | - if(!isset($contestRankRaw)){ |
|
804 | + if (!isset($contestRankRaw)) { |
|
805 | 805 | $contestRankRaw=$this->contestRankCache($cid); |
806 | 806 | } |
807 | - }else{ |
|
808 | - if($clearance == 3){ |
|
807 | + } else { |
|
808 | + if ($clearance==3) { |
|
809 | 809 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
810 | 810 | if (!isset($contestRankRaw)) { |
811 | 811 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
812 | - if(!isset($contestRankRaw)){ |
|
812 | + if (!isset($contestRankRaw)) { |
|
813 | 813 | $contestRankRaw=$this->contestRankCache($cid); |
814 | 814 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
815 | 815 | } |
816 | 816 | } |
817 | - }else{ |
|
817 | + } else { |
|
818 | 818 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
819 | - if(!isset($contestRankRaw)){ |
|
819 | + if (!isset($contestRankRaw)) { |
|
820 | 820 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
821 | - if(!isset($contestRankRaw)){ |
|
821 | + if (!isset($contestRankRaw)) { |
|
822 | 822 | $contestRankRaw=$this->contestRankCache($cid); |
823 | 823 | } |
824 | 824 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
@@ -836,15 +836,15 @@ discard block |
||
836 | 836 | // $contestRankRaw=$this->contestRankCache($cid); |
837 | 837 | // } |
838 | 838 | // } |
839 | - if($contest_info["rule"]==1){ |
|
839 | + if ($contest_info["rule"]==1) { |
|
840 | 840 | foreach ($contestRankRaw as &$cr) { |
841 | - $solved = 0; |
|
842 | - foreach($cr['problem_detail'] as $pd){ |
|
843 | - if(!empty($pd['solved_time_parsed'])){ |
|
844 | - $solved ++; |
|
841 | + $solved=0; |
|
842 | + foreach ($cr['problem_detail'] as $pd) { |
|
843 | + if (!empty($pd['solved_time_parsed'])) { |
|
844 | + $solved++; |
|
845 | 845 | } |
846 | 846 | } |
847 | - $cr['solved'] = $solved; |
|
847 | + $cr['solved']=$solved; |
|
848 | 848 | } |
849 | 849 | } |
850 | 850 | |
@@ -893,16 +893,16 @@ discard block |
||
893 | 893 | |
894 | 894 | public function getClarificationList($cid) |
895 | 895 | { |
896 | - $uid = Auth::user()->id; |
|
897 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
898 | - if($clearance == 3){ |
|
896 | + $uid=Auth::user()->id; |
|
897 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
898 | + if ($clearance==3) { |
|
899 | 899 | return DB::table("contest_clarification")->where([ |
900 | 900 | "cid"=>$cid |
901 | 901 | ])->orderBy('create_time', 'desc')->get()->all(); |
902 | - }else{ |
|
902 | + } else { |
|
903 | 903 | return DB::table("contest_clarification")->where([ |
904 | 904 | "cid"=>$cid |
905 | - ])->where(function ($query) { |
|
905 | + ])->where(function($query) { |
|
906 | 906 | $query->where([ |
907 | 907 | "public"=>1 |
908 | 908 | ])->orWhere([ |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | public function getContestRecord($filter, $cid) |
1048 | 1048 | { |
1049 | 1049 | $basicInfo=$this->basic($cid); |
1050 | - $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first(); |
|
1050 | + $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first(); |
|
1051 | 1051 | $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
1052 | 1052 | "cid"=>$cid |
1053 | 1053 | ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all(); |
@@ -1060,14 +1060,14 @@ discard block |
||
1060 | 1060 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1061 | 1061 | $contestEnd=time()>$end_time; |
1062 | 1062 | |
1063 | - $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1064 | - if($filter['pid']==false){ |
|
1065 | - $filter['pid'] = null; |
|
1066 | - }else{ |
|
1067 | - $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
|
1063 | + $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1064 | + if ($filter['pid']==false) { |
|
1065 | + $filter['pid']=null; |
|
1066 | + } else { |
|
1067 | + $filter['pid']=$problemSet_temp[$filter['pid']]['pid']; |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | - if($userInfo==null || $userInfo["role"]!=3){ |
|
1070 | + if ($userInfo==null || $userInfo["role"]!=3) { |
|
1071 | 1071 | if ($basicInfo["status_visibility"]==2) { |
1072 | 1072 | // View all |
1073 | 1073 | $paginator=DB::table("submission")->where([ |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | "users.id", |
1082 | 1082 | "=", |
1083 | 1083 | "submission.uid" |
1084 | - )->where(function ($query) use ($frozen_time) { |
|
1084 | + )->where(function($query) use ($frozen_time) { |
|
1085 | 1085 | $query->where( |
1086 | 1086 | "submission_date", |
1087 | 1087 | "<", |
@@ -1108,15 +1108,15 @@ discard block |
||
1108 | 1108 | 'desc' |
1109 | 1109 | ); |
1110 | 1110 | |
1111 | - if($filter["pid"]){ |
|
1111 | + if ($filter["pid"]) { |
|
1112 | 1112 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - if($filter["result"]){ |
|
1115 | + if ($filter["result"]) { |
|
1116 | 1116 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - if($filter["account"]){ |
|
1119 | + if ($filter["account"]) { |
|
1120 | 1120 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1121 | 1121 | } |
1122 | 1122 | |
@@ -1152,15 +1152,15 @@ discard block |
||
1152 | 1152 | 'desc' |
1153 | 1153 | ); |
1154 | 1154 | |
1155 | - if($filter["pid"]){ |
|
1155 | + if ($filter["pid"]) { |
|
1156 | 1156 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if($filter["result"]){ |
|
1159 | + if ($filter["result"]) { |
|
1160 | 1160 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - if($filter["account"]){ |
|
1163 | + if ($filter["account"]) { |
|
1164 | 1164 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1165 | 1165 | } |
1166 | 1166 | |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | "records"=>[] |
1172 | 1172 | ]; |
1173 | 1173 | } |
1174 | - }else{ |
|
1174 | + } else { |
|
1175 | 1175 | if ($basicInfo["status_visibility"]==2) { |
1176 | 1176 | // View all |
1177 | 1177 | $paginator=DB::table("submission")->where([ |
@@ -1203,15 +1203,15 @@ discard block |
||
1203 | 1203 | 'desc' |
1204 | 1204 | ); |
1205 | 1205 | |
1206 | - if($filter["pid"]){ |
|
1206 | + if ($filter["pid"]) { |
|
1207 | 1207 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - if($filter["result"]){ |
|
1210 | + if ($filter["result"]) { |
|
1211 | 1211 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1212 | 1212 | } |
1213 | 1213 | |
1214 | - if($filter["account"]){ |
|
1214 | + if ($filter["account"]) { |
|
1215 | 1215 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1247,15 +1247,15 @@ discard block |
||
1247 | 1247 | 'desc' |
1248 | 1248 | ); |
1249 | 1249 | |
1250 | - if($filter["pid"]){ |
|
1250 | + if ($filter["pid"]) { |
|
1251 | 1251 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - if($filter["result"]){ |
|
1254 | + if ($filter["result"]) { |
|
1255 | 1255 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - if($filter["account"]){ |
|
1258 | + if ($filter["account"]) { |
|
1259 | 1259 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1260 | 1260 | } |
1261 | 1261 | |
@@ -1311,21 +1311,21 @@ discard block |
||
1311 | 1311 | if ($uid==0) { |
1312 | 1312 | return 0; |
1313 | 1313 | } |
1314 | - $groupModel = new GroupModel(); |
|
1314 | + $groupModel=new GroupModel(); |
|
1315 | 1315 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
1316 | - $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first(); |
|
1316 | + $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first(); |
|
1317 | 1317 | |
1318 | - if(empty($contest_info)){ |
|
1318 | + if (empty($contest_info)) { |
|
1319 | 1319 | // contest not exist |
1320 | 1320 | return 0; |
1321 | 1321 | } |
1322 | 1322 | |
1323 | - if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){ |
|
1323 | + if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) { |
|
1324 | 1324 | return 3; |
1325 | 1325 | } |
1326 | 1326 | |
1327 | - $contest_started = strtotime($contest_info['begin_time']) < time(); |
|
1328 | - $contest_ended = strtotime($contest_info['end_time']) < time(); |
|
1327 | + $contest_started=strtotime($contest_info['begin_time'])<time(); |
|
1328 | + $contest_ended=strtotime($contest_info['end_time'])<time(); |
|
1329 | 1329 | if (!$contest_started) { |
1330 | 1330 | // not started or do not exist |
1331 | 1331 | return 0; |
@@ -1416,12 +1416,12 @@ discard block |
||
1416 | 1416 | public function updateProfessionalRate($cid) |
1417 | 1417 | { |
1418 | 1418 | $basic=$this->basic($cid); |
1419 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
1419 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
1420 | 1420 | $ratingCalculator=new RatingCalculator($cid); |
1421 | - if($ratingCalculator->calculate()){ |
|
1421 | + if ($ratingCalculator->calculate()) { |
|
1422 | 1422 | $ratingCalculator->storage(); |
1423 | 1423 | return true; |
1424 | - }else{ |
|
1424 | + } else { |
|
1425 | 1425 | return false; |
1426 | 1426 | } |
1427 | 1427 | } else { |
@@ -1429,26 +1429,26 @@ discard block |
||
1429 | 1429 | } |
1430 | 1430 | } |
1431 | 1431 | |
1432 | - public function contestUpdate($cid,$data,$problems) |
|
1432 | + public function contestUpdate($cid, $data, $problems) |
|
1433 | 1433 | { |
1434 | - if($problems !== false){ |
|
1435 | - $old_problmes = array_column( |
|
1434 | + if ($problems!==false) { |
|
1435 | + $old_problmes=array_column( |
|
1436 | 1436 | DB::table('contest_problem') |
1437 | - ->where('cid',$cid) |
|
1437 | + ->where('cid', $cid) |
|
1438 | 1438 | ->get()->all(), |
1439 | 1439 | 'pid' |
1440 | 1440 | ); |
1441 | - DB::transaction(function () use ($cid, $data, $problems,$old_problmes) { |
|
1441 | + DB::transaction(function() use ($cid, $data, $problems, $old_problmes) { |
|
1442 | 1442 | DB::table($this->tableName) |
1443 | - ->where('cid',$cid) |
|
1443 | + ->where('cid', $cid) |
|
1444 | 1444 | ->update($data); |
1445 | 1445 | DB::table('contest_problem') |
1446 | - ->where('cid',$cid) |
|
1446 | + ->where('cid', $cid) |
|
1447 | 1447 | ->delete(); |
1448 | - $new_problems = []; |
|
1448 | + $new_problems=[]; |
|
1449 | 1449 | foreach ($problems as $p) { |
1450 | 1450 | $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"]; |
1451 | - array_push($new_problems,$pid); |
|
1451 | + array_push($new_problems, $pid); |
|
1452 | 1452 | DB::table("contest_problem")->insert([ |
1453 | 1453 | "cid"=>$cid, |
1454 | 1454 | "number"=>$p["number"], |
@@ -1458,29 +1458,29 @@ discard block |
||
1458 | 1458 | "points"=>$p["points"] |
1459 | 1459 | ]); |
1460 | 1460 | } |
1461 | - foreach($old_problmes as $op) { |
|
1462 | - if(!in_array($op,$new_problems)){ |
|
1461 | + foreach ($old_problmes as $op) { |
|
1462 | + if (!in_array($op, $new_problems)) { |
|
1463 | 1463 | DB::table('submission') |
1464 | - ->where('cid',$cid) |
|
1465 | - ->where('pid',$op) |
|
1464 | + ->where('cid', $cid) |
|
1465 | + ->where('pid', $op) |
|
1466 | 1466 | ->delete(); |
1467 | 1467 | } |
1468 | 1468 | } |
1469 | 1469 | }, 5); |
1470 | - $contestRankRaw = $this->contestRankCache($cid); |
|
1470 | + $contestRankRaw=$this->contestRankCache($cid); |
|
1471 | 1471 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1472 | 1472 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1473 | - }else{ |
|
1473 | + } else { |
|
1474 | 1474 | DB::table($this->tableName) |
1475 | - ->where('cid',$cid) |
|
1475 | + ->where('cid', $cid) |
|
1476 | 1476 | ->update($data); |
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | |
1480 | - public function contestUpdateProblem($cid,$problems) |
|
1480 | + public function contestUpdateProblem($cid, $problems) |
|
1481 | 1481 | { |
1482 | 1482 | DB::table('contest_problem') |
1483 | - ->where('cid',$cid) |
|
1483 | + ->where('cid', $cid) |
|
1484 | 1484 | ->delete(); |
1485 | 1485 | foreach ($problems as $p) { |
1486 | 1486 | DB::table("contest_problem")->insertGetId([ |
@@ -1496,8 +1496,8 @@ discard block |
||
1496 | 1496 | |
1497 | 1497 | public function arrangeContest($gid, $config, $problems) |
1498 | 1498 | { |
1499 | - $cid = -1; |
|
1500 | - DB::transaction(function () use ($gid, $config, $problems,&$cid) { |
|
1499 | + $cid=-1; |
|
1500 | + DB::transaction(function() use ($gid, $config, $problems, &$cid) { |
|
1501 | 1501 | $cid=DB::table($this->tableName)->insertGetId([ |
1502 | 1502 | "gid"=>$gid, |
1503 | 1503 | "name"=>$config["name"], |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | "rule"=>1, //todo |
1512 | 1512 | "begin_time"=>$config["begin_time"], |
1513 | 1513 | "end_time"=>$config["end_time"], |
1514 | - "vcid"=>isset($config["vcid"])?$config["vcid"]:null, |
|
1514 | + "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null, |
|
1515 | 1515 | "public"=>$config["public"], |
1516 | 1516 | "registration"=>0, //todo |
1517 | 1517 | "registration_due"=>null, //todo |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | "froze_length"=>0, //todo |
1520 | 1520 | "status_visibility"=>2, //todo |
1521 | 1521 | "create_time"=>date("Y-m-d H:i:s"), |
1522 | - "crawled" => isset($config['vcid'])?$config['crawled'] : null, |
|
1522 | + "crawled" => isset($config['vcid']) ? $config['crawled'] : null, |
|
1523 | 1523 | "audit_status"=>$config["public"] ? 0 : 1 |
1524 | 1524 | ]); |
1525 | 1525 | |
@@ -1538,13 +1538,13 @@ discard block |
||
1538 | 1538 | return $cid; |
1539 | 1539 | } |
1540 | 1540 | |
1541 | - public function updateContestRankTable($cid,$sub) |
|
1541 | + public function updateContestRankTable($cid, $sub) |
|
1542 | 1542 | { |
1543 | - $lock = Cache::lock("contestrank$cid",10); |
|
1544 | - try{ |
|
1545 | - if($lock->get()){ |
|
1546 | - if(Cache::tags(['contest','rank'])->get($cid) != null){ |
|
1547 | - $ret = Cache::tags(['contest','rank'])->get($cid); |
|
1543 | + $lock=Cache::lock("contestrank$cid", 10); |
|
1544 | + try { |
|
1545 | + if ($lock->get()) { |
|
1546 | + if (Cache::tags(['contest', 'rank'])->get($cid)!=null) { |
|
1547 | + $ret=Cache::tags(['contest', 'rank'])->get($cid); |
|
1548 | 1548 | $chache=[]; |
1549 | 1549 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
1550 | 1550 | $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
@@ -1553,27 +1553,27 @@ discard block |
||
1553 | 1553 | $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"]; |
1554 | 1554 | $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1555 | 1555 | |
1556 | - $id = 0; |
|
1556 | + $id=0; |
|
1557 | 1557 | |
1558 | - foreach($chache['problemSet'] as $key => $p){ |
|
1559 | - if ($p['pid'] == $sub['pid']){ |
|
1560 | - $chache['problemSet'][$key]['cpid'] = $key; |
|
1561 | - $id = $key; |
|
1558 | + foreach ($chache['problemSet'] as $key => $p) { |
|
1559 | + if ($p['pid']==$sub['pid']) { |
|
1560 | + $chache['problemSet'][$key]['cpid']=$key; |
|
1561 | + $id=$key; |
|
1562 | 1562 | } |
1563 | 1563 | } |
1564 | 1564 | |
1565 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret); |
|
1566 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1565 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret); |
|
1566 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1567 | 1567 | |
1568 | - if (time() < $chache['frozen_time']){ |
|
1568 | + if (time()<$chache['frozen_time']) { |
|
1569 | 1569 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1570 | 1570 | } |
1571 | 1571 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret); |
1572 | - if(time() > $chache['end_time']){ |
|
1572 | + if (time()>$chache['end_time']) { |
|
1573 | 1573 | $this->storeContestRankInMySQL($cid, $ret); |
1574 | 1574 | } |
1575 | 1575 | } |
1576 | - else{ |
|
1576 | + else { |
|
1577 | 1577 | $ret=[]; |
1578 | 1578 | $chache=[]; |
1579 | 1579 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | "cid"=>$cid, |
1589 | 1589 | "audit"=>1 |
1590 | 1590 | ])->select('uid')->get()->all(); |
1591 | - }else{ |
|
1591 | + } else { |
|
1592 | 1592 | $submissionUsers=DB::table("submission")->where([ |
1593 | 1593 | "cid"=>$cid |
1594 | 1594 | ])->where( |
@@ -1601,39 +1601,39 @@ discard block |
||
1601 | 1601 | ])->select('uid')->groupBy('uid')->get()->all(); |
1602 | 1602 | } |
1603 | 1603 | |
1604 | - $chacheAdmin = $chache; |
|
1604 | + $chacheAdmin=$chache; |
|
1605 | 1605 | |
1606 | 1606 | foreach ($submissionUsers as $s) { |
1607 | 1607 | foreach ($chache['problemSet'] as $key => $p) { |
1608 | - $p['cpid'] = $key; |
|
1609 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret); |
|
1608 | + $p['cpid']=$key; |
|
1609 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret); |
|
1610 | 1610 | } |
1611 | 1611 | } |
1612 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1612 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1613 | 1613 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1614 | 1614 | |
1615 | 1615 | $retAdmin=[]; |
1616 | 1616 | foreach ($submissionUsersAdmin as $s) { |
1617 | 1617 | foreach ($chacheAdmin['problemSet'] as $key => $p) { |
1618 | - $p['cpid'] = $key; |
|
1619 | - $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin); |
|
1618 | + $p['cpid']=$key; |
|
1619 | + $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin); |
|
1620 | 1620 | } |
1621 | 1621 | } |
1622 | - $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin); |
|
1622 | + $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin); |
|
1623 | 1623 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1624 | 1624 | } |
1625 | 1625 | } |
1626 | - }catch(LockTimeoutException $e){ |
|
1626 | + } catch (LockTimeoutException $e) { |
|
1627 | 1627 | Log::warning("Contest Rank Lock Timed Out"); |
1628 | - }finally{ |
|
1628 | + } finally { |
|
1629 | 1629 | optional($lock)->release(); |
1630 | 1630 | } |
1631 | 1631 | } |
1632 | 1632 | |
1633 | - public function sortContestRankTable($contest_info,$cid,$ret) |
|
1633 | + public function sortContestRankTable($contest_info, $cid, $ret) |
|
1634 | 1634 | { |
1635 | - if ($contest_info["rule"]==1){ |
|
1636 | - usort($ret, function ($a, $b) { |
|
1635 | + if ($contest_info["rule"]==1) { |
|
1636 | + usort($ret, function($a, $b) { |
|
1637 | 1637 | if ($a["score"]==$b["score"]) { |
1638 | 1638 | if ($a["penalty"]==$b["penalty"]) { |
1639 | 1639 | return 0; |
@@ -1648,8 +1648,8 @@ discard block |
||
1648 | 1648 | return 1; |
1649 | 1649 | } |
1650 | 1650 | }); |
1651 | - }else if ($contest_info["rule"]==2){ |
|
1652 | - usort($ret, function ($a, $b) { |
|
1651 | + } else if ($contest_info["rule"]==2) { |
|
1652 | + usort($ret, function($a, $b) { |
|
1653 | 1653 | if ($a["score"]==$b["score"]) { |
1654 | 1654 | if ($a["solved"]==$b["solved"]) { |
1655 | 1655 | return 0; |
@@ -1668,21 +1668,21 @@ discard block |
||
1668 | 1668 | return $ret; |
1669 | 1669 | } |
1670 | 1670 | |
1671 | - public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret) |
|
1671 | + public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret) |
|
1672 | 1672 | { |
1673 | - $id = count($ret); |
|
1674 | - foreach($ret as $key => $r){ |
|
1675 | - if($r['uid'] == $uid) |
|
1676 | - $id = $key; |
|
1673 | + $id=count($ret); |
|
1674 | + foreach ($ret as $key => $r) { |
|
1675 | + if ($r['uid']==$uid) |
|
1676 | + $id=$key; |
|
1677 | 1677 | } |
1678 | 1678 | if ($contest_info["rule"]==1) { |
1679 | 1679 | // ACM/ICPC Mode |
1680 | - if($id == count($ret)){ |
|
1681 | - $prob_detail = []; |
|
1682 | - $totPen = 0; |
|
1683 | - $totScore = 0; |
|
1684 | - }else{ |
|
1685 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1680 | + if ($id==count($ret)) { |
|
1681 | + $prob_detail=[]; |
|
1682 | + $totPen=0; |
|
1683 | + $totScore=0; |
|
1684 | + } else { |
|
1685 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1686 | 1686 | $totPen=$ret[$id]['penalty']; |
1687 | 1687 | $totScore=$ret[$id]['score']; |
1688 | 1688 | }; |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | "uid"=>$uid, |
1701 | 1701 | ])->orderBy('submission_date', 'desc')->first(); |
1702 | 1702 | |
1703 | - if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){ |
|
1703 | + if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") { |
|
1704 | 1704 | $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid); |
1705 | 1705 | |
1706 | 1706 | $prob_detail[$problem['cpid']]=[ |
@@ -1732,12 +1732,12 @@ discard block |
||
1732 | 1732 | } |
1733 | 1733 | } elseif ($contest_info["rule"]==2) { |
1734 | 1734 | // OI Mode |
1735 | - if($id == count($ret)){ |
|
1736 | - $prob_detail = []; |
|
1737 | - $totSolved = 0; |
|
1738 | - $totScore = 0; |
|
1739 | - }else{ |
|
1740 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1735 | + if ($id==count($ret)) { |
|
1736 | + $prob_detail=[]; |
|
1737 | + $totSolved=0; |
|
1738 | + $totScore=0; |
|
1739 | + } else { |
|
1740 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1741 | 1741 | $totSolved=$ret[$id]['solved']; |
1742 | 1742 | $totScore=$ret[$id]['score']; |
1743 | 1743 | }; |
@@ -1770,47 +1770,47 @@ discard block |
||
1770 | 1770 | return $ret; |
1771 | 1771 | } |
1772 | 1772 | |
1773 | - public function assignMember($cid,$uid){ |
|
1773 | + public function assignMember($cid, $uid) { |
|
1774 | 1774 | return DB::table("contest")->where(["cid"=>$cid])->update([ |
1775 | 1775 | "assign_uid"=>$uid |
1776 | 1776 | ]); |
1777 | 1777 | } |
1778 | 1778 | |
1779 | - public function canUpdateContestTime($cid,$time = []) |
|
1779 | + public function canUpdateContestTime($cid, $time=[]) |
|
1780 | 1780 | { |
1781 | - $begin_time_new = $time['begin'] ?? null; |
|
1782 | - $end_time_new = $time['end'] ?? null; |
|
1781 | + $begin_time_new=$time['begin'] ?? null; |
|
1782 | + $end_time_new=$time['end'] ?? null; |
|
1783 | 1783 | |
1784 | - $hold_time = DB::table('contest') |
|
1785 | - ->where('cid',$cid) |
|
1786 | - ->select('begin_time','end_time') |
|
1784 | + $hold_time=DB::table('contest') |
|
1785 | + ->where('cid', $cid) |
|
1786 | + ->select('begin_time', 'end_time') |
|
1787 | 1787 | ->first(); |
1788 | - $begin_stamps = strtotime($hold_time['begin_time']); |
|
1789 | - $end_stamps = strtotime($hold_time['end_time']); |
|
1788 | + $begin_stamps=strtotime($hold_time['begin_time']); |
|
1789 | + $end_stamps=strtotime($hold_time['end_time']); |
|
1790 | 1790 | /* |
1791 | 1791 | -1 : have not begun |
1792 | 1792 | 0 : ing |
1793 | 1793 | 1 : end |
1794 | 1794 | */ |
1795 | - $status = time() >= $end_stamps ? 1 |
|
1796 | - : (time() <= $begin_stamps ? -1 : 0); |
|
1797 | - if($status === -1){ |
|
1798 | - if(time() > $begin_time_new){ |
|
1795 | + $status=time()>=$end_stamps ? 1 |
|
1796 | + : (time()<=$begin_stamps ? -1 : 0); |
|
1797 | + if ($status===-1) { |
|
1798 | + if (time()>$begin_time_new) { |
|
1799 | 1799 | return false; |
1800 | 1800 | } |
1801 | 1801 | return true; |
1802 | - }else if($status === 0){ |
|
1803 | - if($begin_time_new !== null){ |
|
1802 | + } else if ($status===0) { |
|
1803 | + if ($begin_time_new!==null) { |
|
1804 | 1804 | return false; |
1805 | 1805 | } |
1806 | - if($end_time_new !== null){ |
|
1807 | - if(strtotime($end_time_new) <= time()){ |
|
1806 | + if ($end_time_new!==null) { |
|
1807 | + if (strtotime($end_time_new)<=time()) { |
|
1808 | 1808 | return false; |
1809 | - }else{ |
|
1809 | + } else { |
|
1810 | 1810 | return true; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | - }else{ |
|
1813 | + } else { |
|
1814 | 1814 | return false; |
1815 | 1815 | } |
1816 | 1816 | |
@@ -1819,22 +1819,22 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | public function replyClarification($ccid, $content) |
1821 | 1821 | { |
1822 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1822 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1823 | 1823 | "reply"=>$content |
1824 | 1824 | ]); |
1825 | 1825 | } |
1826 | 1826 | |
1827 | 1827 | public function setClarificationPublic($ccid, $public) |
1828 | 1828 | { |
1829 | - if($public) |
|
1829 | + if ($public) |
|
1830 | 1830 | { |
1831 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1831 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1832 | 1832 | "public"=>1 |
1833 | 1833 | ]); |
1834 | 1834 | } |
1835 | 1835 | else |
1836 | 1836 | { |
1837 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1837 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1838 | 1838 | "public"=>0 |
1839 | 1839 | ]); |
1840 | 1840 | } |
@@ -1845,82 +1845,82 @@ discard block |
||
1845 | 1845 | return Cache::tags(['contest', 'account'])->get($cid); |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - public function praticeAnalysis($cid){ |
|
1849 | - $gid = DB::table('contest') |
|
1850 | - ->where('cid',$cid) |
|
1848 | + public function praticeAnalysis($cid) { |
|
1849 | + $gid=DB::table('contest') |
|
1850 | + ->where('cid', $cid) |
|
1851 | 1851 | ->first()['gid']; |
1852 | - $contestRank = $this->contestRank($cid,Auth::user()->id); |
|
1853 | - if(!empty($contestRank)){ |
|
1854 | - $all_problems = DB::table('problem') |
|
1855 | - ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
|
1856 | - ->select('pid','title') |
|
1852 | + $contestRank=$this->contestRank($cid, Auth::user()->id); |
|
1853 | + if (!empty($contestRank)) { |
|
1854 | + $all_problems=DB::table('problem') |
|
1855 | + ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid')) |
|
1856 | + ->select('pid', 'title') |
|
1857 | 1857 | ->get()->all(); |
1858 | - }else{ |
|
1859 | - $all_problems = []; |
|
1858 | + } else { |
|
1859 | + $all_problems=[]; |
|
1860 | 1860 | } |
1861 | - $tags = DB::table('group_problem_tag') |
|
1861 | + $tags=DB::table('group_problem_tag') |
|
1862 | 1862 | ->where('gid', $gid) |
1863 | - ->whereIn('pid', array_column($all_problems,'pid')) |
|
1863 | + ->whereIn('pid', array_column($all_problems, 'pid')) |
|
1864 | 1864 | ->get()->all(); |
1865 | - $all_tags = array_unique(array_column($tags,'tag')); |
|
1866 | - $memberData = []; |
|
1867 | - foreach($contestRank as $member){ |
|
1868 | - $m = [ |
|
1865 | + $all_tags=array_unique(array_column($tags, 'tag')); |
|
1866 | + $memberData=[]; |
|
1867 | + foreach ($contestRank as $member) { |
|
1868 | + $m=[ |
|
1869 | 1869 | 'uid' => $member['uid'], |
1870 | 1870 | 'name' => $member['name'], |
1871 | 1871 | 'nick_name' => $member['nick_name'], |
1872 | 1872 | ]; |
1873 | - $completion = []; |
|
1874 | - foreach ($all_tags as $tag){ |
|
1875 | - $completion[$tag] = []; |
|
1873 | + $completion=[]; |
|
1874 | + foreach ($all_tags as $tag) { |
|
1875 | + $completion[$tag]=[]; |
|
1876 | 1876 | foreach ($tags as $t) { |
1877 | - if($t['tag'] == $tag){ |
|
1877 | + if ($t['tag']==$tag) { |
|
1878 | 1878 | foreach ($member['problem_detail'] as $pd) { |
1879 | - if($pd['pid'] == $t['pid']){ |
|
1880 | - $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1; |
|
1879 | + if ($pd['pid']==$t['pid']) { |
|
1880 | + $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1; |
|
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | } |
1885 | 1885 | } |
1886 | - $m['completion'] = $completion; |
|
1887 | - $memberData[] = $m; |
|
1886 | + $m['completion']=$completion; |
|
1887 | + $memberData[]=$m; |
|
1888 | 1888 | } |
1889 | 1889 | return $memberData; |
1890 | 1890 | } |
1891 | 1891 | |
1892 | 1892 | public function storeContestRankInMySQL($cid, $data) |
1893 | 1893 | { |
1894 | - $contestRankJson = json_encode($data); |
|
1895 | - return DB::table('contest')->where('cid','=',$cid)->update([ |
|
1894 | + $contestRankJson=json_encode($data); |
|
1895 | + return DB::table('contest')->where('cid', '=', $cid)->update([ |
|
1896 | 1896 | 'rank' => $contestRankJson |
1897 | 1897 | ]); |
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | public function getContestRankFromMySQL($cid) |
1901 | 1901 | { |
1902 | - $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first(); |
|
1903 | - $data = json_decode($contestRankJson, true); |
|
1902 | + $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first(); |
|
1903 | + $data=json_decode($contestRankJson, true); |
|
1904 | 1904 | return $data; |
1905 | 1905 | } |
1906 | 1906 | |
1907 | 1907 | public function isVerified($cid) |
1908 | 1908 | { |
1909 | - return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first(); |
|
1909 | + return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first(); |
|
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | public function judgeOver($cid) |
1913 | 1913 | { |
1914 | - $submissions = DB::table('submission') |
|
1914 | + $submissions=DB::table('submission') |
|
1915 | 1915 | ->where(['cid' => $cid]) |
1916 | - ->whereIn('verdict',['Waiting','Pending']) |
|
1916 | + ->whereIn('verdict', ['Waiting', 'Pending']) |
|
1917 | 1917 | ->select('sid') |
1918 | 1918 | ->get()->all(); |
1919 | - if(empty($submissions)){ |
|
1919 | + if (empty($submissions)) { |
|
1920 | 1920 | return [ |
1921 | 1921 | 'result' => true |
1922 | 1922 | ]; |
1923 | - }else{ |
|
1923 | + } else { |
|
1924 | 1924 | return [ |
1925 | 1925 | 'result' => false, |
1926 | 1926 | 'sid' => $submissions |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
226 | 226 | } |
227 | 227 | $paginator = $paginator ->paginate(10); |
228 | - }elseif($filter['public']=='0'){ |
|
228 | + } elseif($filter['public']=='0'){ |
|
229 | 229 | $paginator=DB::table('group_member') |
230 | 230 | ->groupBy('contest.cid') |
231 | 231 | ->select('contest.*') |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | ) |
256 | 256 | ->orderBy('contest.begin_time', 'desc') |
257 | 257 | ->paginate(10); |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | $paginator=DB::table('group_member') |
260 | 260 | ->groupBy('contest.cid') |
261 | 261 | ->select('contest.*') |
@@ -798,13 +798,13 @@ discard block |
||
798 | 798 | if(time() < $end_time){ |
799 | 799 | if($clearance == 3){ |
800 | 800 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
801 | - }else{ |
|
801 | + } else{ |
|
802 | 802 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
803 | 803 | } |
804 | 804 | if(!isset($contestRankRaw)){ |
805 | 805 | $contestRankRaw=$this->contestRankCache($cid); |
806 | 806 | } |
807 | - }else{ |
|
807 | + } else{ |
|
808 | 808 | if($clearance == 3){ |
809 | 809 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
810 | 810 | if (!isset($contestRankRaw)) { |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
815 | 815 | } |
816 | 816 | } |
817 | - }else{ |
|
817 | + } else{ |
|
818 | 818 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
819 | 819 | if(!isset($contestRankRaw)){ |
820 | 820 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | return DB::table("contest_clarification")->where([ |
900 | 900 | "cid"=>$cid |
901 | 901 | ])->orderBy('create_time', 'desc')->get()->all(); |
902 | - }else{ |
|
902 | + } else{ |
|
903 | 903 | return DB::table("contest_clarification")->where([ |
904 | 904 | "cid"=>$cid |
905 | 905 | ])->where(function ($query) { |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
1064 | 1064 | if($filter['pid']==false){ |
1065 | 1065 | $filter['pid'] = null; |
1066 | - }else{ |
|
1066 | + } else{ |
|
1067 | 1067 | $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | "records"=>[] |
1172 | 1172 | ]; |
1173 | 1173 | } |
1174 | - }else{ |
|
1174 | + } else{ |
|
1175 | 1175 | if ($basicInfo["status_visibility"]==2) { |
1176 | 1176 | // View all |
1177 | 1177 | $paginator=DB::table("submission")->where([ |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | if($ratingCalculator->calculate()){ |
1422 | 1422 | $ratingCalculator->storage(); |
1423 | 1423 | return true; |
1424 | - }else{ |
|
1424 | + } else{ |
|
1425 | 1425 | return false; |
1426 | 1426 | } |
1427 | 1427 | } else { |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | $contestRankRaw = $this->contestRankCache($cid); |
1471 | 1471 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1472 | 1472 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1473 | - }else{ |
|
1473 | + } else{ |
|
1474 | 1474 | DB::table($this->tableName) |
1475 | 1475 | ->where('cid',$cid) |
1476 | 1476 | ->update($data); |
@@ -1572,8 +1572,7 @@ discard block |
||
1572 | 1572 | if(time() > $chache['end_time']){ |
1573 | 1573 | $this->storeContestRankInMySQL($cid, $ret); |
1574 | 1574 | } |
1575 | - } |
|
1576 | - else{ |
|
1575 | + } else{ |
|
1577 | 1576 | $ret=[]; |
1578 | 1577 | $chache=[]; |
1579 | 1578 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1588,7 +1587,7 @@ discard block |
||
1588 | 1587 | "cid"=>$cid, |
1589 | 1588 | "audit"=>1 |
1590 | 1589 | ])->select('uid')->get()->all(); |
1591 | - }else{ |
|
1590 | + } else{ |
|
1592 | 1591 | $submissionUsers=DB::table("submission")->where([ |
1593 | 1592 | "cid"=>$cid |
1594 | 1593 | ])->where( |
@@ -1623,9 +1622,9 @@ discard block |
||
1623 | 1622 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1624 | 1623 | } |
1625 | 1624 | } |
1626 | - }catch(LockTimeoutException $e){ |
|
1625 | + } catch(LockTimeoutException $e){ |
|
1627 | 1626 | Log::warning("Contest Rank Lock Timed Out"); |
1628 | - }finally{ |
|
1627 | + } finally{ |
|
1629 | 1628 | optional($lock)->release(); |
1630 | 1629 | } |
1631 | 1630 | } |
@@ -1648,7 +1647,7 @@ discard block |
||
1648 | 1647 | return 1; |
1649 | 1648 | } |
1650 | 1649 | }); |
1651 | - }else if ($contest_info["rule"]==2){ |
|
1650 | + } else if ($contest_info["rule"]==2){ |
|
1652 | 1651 | usort($ret, function ($a, $b) { |
1653 | 1652 | if ($a["score"]==$b["score"]) { |
1654 | 1653 | if ($a["solved"]==$b["solved"]) { |
@@ -1672,8 +1671,9 @@ discard block |
||
1672 | 1671 | { |
1673 | 1672 | $id = count($ret); |
1674 | 1673 | foreach($ret as $key => $r){ |
1675 | - if($r['uid'] == $uid) |
|
1676 | - $id = $key; |
|
1674 | + if($r['uid'] == $uid) { |
|
1675 | + $id = $key; |
|
1676 | + } |
|
1677 | 1677 | } |
1678 | 1678 | if ($contest_info["rule"]==1) { |
1679 | 1679 | // ACM/ICPC Mode |
@@ -1681,7 +1681,7 @@ discard block |
||
1681 | 1681 | $prob_detail = []; |
1682 | 1682 | $totPen = 0; |
1683 | 1683 | $totScore = 0; |
1684 | - }else{ |
|
1684 | + } else{ |
|
1685 | 1685 | $prob_detail = $ret[$id]['problem_detail']; |
1686 | 1686 | $totPen=$ret[$id]['penalty']; |
1687 | 1687 | $totScore=$ret[$id]['score']; |
@@ -1736,7 +1736,7 @@ discard block |
||
1736 | 1736 | $prob_detail = []; |
1737 | 1737 | $totSolved = 0; |
1738 | 1738 | $totScore = 0; |
1739 | - }else{ |
|
1739 | + } else{ |
|
1740 | 1740 | $prob_detail = $ret[$id]['problem_detail']; |
1741 | 1741 | $totSolved=$ret[$id]['solved']; |
1742 | 1742 | $totScore=$ret[$id]['score']; |
@@ -1799,18 +1799,18 @@ discard block |
||
1799 | 1799 | return false; |
1800 | 1800 | } |
1801 | 1801 | return true; |
1802 | - }else if($status === 0){ |
|
1802 | + } else if($status === 0){ |
|
1803 | 1803 | if($begin_time_new !== null){ |
1804 | 1804 | return false; |
1805 | 1805 | } |
1806 | 1806 | if($end_time_new !== null){ |
1807 | 1807 | if(strtotime($end_time_new) <= time()){ |
1808 | 1808 | return false; |
1809 | - }else{ |
|
1809 | + } else{ |
|
1810 | 1810 | return true; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | - }else{ |
|
1813 | + } else{ |
|
1814 | 1814 | return false; |
1815 | 1815 | } |
1816 | 1816 | |
@@ -1831,8 +1831,7 @@ discard block |
||
1831 | 1831 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1832 | 1832 | "public"=>1 |
1833 | 1833 | ]); |
1834 | - } |
|
1835 | - else |
|
1834 | + } else |
|
1836 | 1835 | { |
1837 | 1836 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1838 | 1837 | "public"=>0 |
@@ -1855,7 +1854,7 @@ discard block |
||
1855 | 1854 | ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
1856 | 1855 | ->select('pid','title') |
1857 | 1856 | ->get()->all(); |
1858 | - }else{ |
|
1857 | + } else{ |
|
1859 | 1858 | $all_problems = []; |
1860 | 1859 | } |
1861 | 1860 | $tags = DB::table('group_problem_tag') |
@@ -1920,7 +1919,7 @@ discard block |
||
1920 | 1919 | return [ |
1921 | 1920 | 'result' => true |
1922 | 1921 | ]; |
1923 | - }else{ |
|
1922 | + } else{ |
|
1924 | 1923 | return [ |
1925 | 1924 | 'result' => false, |
1926 | 1925 | 'sid' => $submissions |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | foreach ($trending_groups as &$t) { |
59 | 59 | $t["members"]=$this->countGroupMembers($t["gid"]); |
60 | 60 | } |
61 | - usort($trending_groups, function ($a, $b) { |
|
61 | + usort($trending_groups, function($a, $b) { |
|
62 | 62 | return $b["members"]<=>$a["members"]; |
63 | 63 | }); |
64 | - Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24); |
|
64 | + Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function userGroups($uid) |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | |
102 | 102 | public function changeGroupName($gid, $GroupName) |
103 | 103 | { |
104 | - return DB::table("group")->where('gid',$gid)->update([ |
|
104 | + return DB::table("group")->where('gid', $gid)->update([ |
|
105 | 105 | "name"=>$GroupName |
106 | 106 | ]); |
107 | 107 | } |
108 | 108 | |
109 | - public function changeJoinPolicy($gid, $JoinPolicy){ |
|
110 | - return DB::table("group")->where('gid',$gid)->update([ |
|
109 | + public function changeJoinPolicy($gid, $JoinPolicy) { |
|
110 | + return DB::table("group")->where('gid', $gid)->update([ |
|
111 | 111 | "join_policy"=>$JoinPolicy |
112 | 112 | ]); |
113 | 113 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function details($gcode) |
116 | 116 | { |
117 | 117 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
118 | - if(empty($basic_info)) return []; |
|
118 | + if (empty($basic_info)) return []; |
|
119 | 119 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
120 | 120 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
121 | 121 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y'); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | public function userProfile($uid, $gid) |
133 | 133 | { |
134 | 134 | $info=DB::table("group_member") |
135 | - ->join('users','users.id','=','group_member.uid') |
|
135 | + ->join('users', 'users.id', '=', 'group_member.uid') |
|
136 | 136 | ->where(["gid"=>$gid, "uid"=>$uid]) |
137 | 137 | ->where("role", ">", 0) |
138 | - ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group') |
|
138 | + ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group') |
|
139 | 139 | ->first(); |
140 | 140 | if (!empty($info)) { |
141 | 141 | $info["role_parsed"]=$this->role[$info["role"]]; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | foreach ($user_list as &$u) { |
164 | 164 | $u["role_parsed"]=$this->role[$u["role"]]; |
165 | 165 | $u["role_color"]=$this->role_color[$u["role"]]; |
166 | - if(is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
166 | + if (is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
167 | 167 | } |
168 | 168 | return $user_list; |
169 | 169 | } |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | ])->where("role", ">", 0)->count(); |
225 | 225 | } |
226 | 226 | |
227 | - public function problemTags($gid,$pid = -1) |
|
227 | + public function problemTags($gid, $pid=-1) |
|
228 | 228 | { |
229 | - if($pid == -1){ |
|
230 | - $tags = DB::table('group_problem_tag') |
|
229 | + if ($pid==-1) { |
|
230 | + $tags=DB::table('group_problem_tag') |
|
231 | 231 | ->select('tag') |
232 | - ->where('gid',$gid) |
|
232 | + ->where('gid', $gid) |
|
233 | 233 | ->distinct() |
234 | 234 | ->get()->all(); |
235 | - }else{ |
|
236 | - $tags = DB::table('group_problem_tag') |
|
235 | + } else { |
|
236 | + $tags=DB::table('group_problem_tag') |
|
237 | 237 | ->select('tag') |
238 | 238 | ->where('gid', $gid) |
239 | 239 | ->where('pid', $pid) |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | ->get()->all(); |
242 | 242 | } |
243 | 243 | |
244 | - $tags_arr = []; |
|
245 | - if(!empty($tags)){ |
|
244 | + $tags_arr=[]; |
|
245 | + if (!empty($tags)) { |
|
246 | 246 | foreach ($tags as $value) { |
247 | - array_push($tags_arr,$value['tag']); |
|
247 | + array_push($tags_arr, $value['tag']); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | return $tags_arr; |
@@ -252,28 +252,28 @@ discard block |
||
252 | 252 | |
253 | 253 | public function problems($gid) |
254 | 254 | { |
255 | - $contestModel = new ContestModel(); |
|
256 | - $problems = DB::table('contest_problem') |
|
257 | - ->join('contest','contest_problem.cid', '=', 'contest.cid') |
|
258 | - ->join('problem','contest_problem.pid', '=', 'problem.pid' ) |
|
255 | + $contestModel=new ContestModel(); |
|
256 | + $problems=DB::table('contest_problem') |
|
257 | + ->join('contest', 'contest_problem.cid', '=', 'contest.cid') |
|
258 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
259 | 259 | ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title') |
260 | - ->where('contest.gid',$gid) |
|
261 | - ->where('contest.practice',1) |
|
262 | - ->orderBy('contest.create_time','desc') |
|
260 | + ->where('contest.gid', $gid) |
|
261 | + ->where('contest.practice', 1) |
|
262 | + ->orderBy('contest.create_time', 'desc') |
|
263 | 263 | ->distinct() |
264 | 264 | ->get()->all(); |
265 | - $user_id = Auth::user()->id; |
|
266 | - foreach($problems as $key => $value){ |
|
267 | - if($contestModel->judgeClearance($value['cid'],$user_id) != 3){ |
|
265 | + $user_id=Auth::user()->id; |
|
266 | + foreach ($problems as $key => $value) { |
|
267 | + if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) { |
|
268 | 268 | unset($problems[$key]); |
269 | - }else{ |
|
270 | - $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']); |
|
269 | + } else { |
|
270 | + $problems[$key]['tags']=$this->problemTags($gid, $value['pid']); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | return $problems; |
274 | 274 | } |
275 | 275 | |
276 | - public function problemAddTag($gid,$pid,$tag) |
|
276 | + public function problemAddTag($gid, $pid, $tag) |
|
277 | 277 | { |
278 | 278 | return DB::table("group_problem_tag")->insert([ |
279 | 279 | "gid"=>$gid, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ]); |
283 | 283 | } |
284 | 284 | |
285 | - public function problemRemoveTag($gid,$pid,$tag) |
|
285 | + public function problemRemoveTag($gid, $pid, $tag) |
|
286 | 286 | { |
287 | 287 | return DB::table("group_problem_tag")->where([ |
288 | 288 | "gid"=>$gid, |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | public function judgeEmailClearance($gid, $email) |
328 | 328 | { |
329 | 329 | $user=DB::table("users")->where(["email"=>$email])->first(); |
330 | - if(empty($user)) return -4; |
|
330 | + if (empty($user)) return -4; |
|
331 | 331 | $ret=DB::table("group_member")->where([ |
332 | 332 | "gid"=>$gid, |
333 | 333 | "uid"=>$user["id"], |
@@ -418,20 +418,20 @@ discard block |
||
418 | 418 | |
419 | 419 | public function groupMemberPracticeContestStat($gid) |
420 | 420 | { |
421 | - $contestModel = new ContestModel(); |
|
421 | + $contestModel=new ContestModel(); |
|
422 | 422 | |
423 | - $allPracticeContest = DB::table('contest') |
|
423 | + $allPracticeContest=DB::table('contest') |
|
424 | 424 | ->where([ |
425 | 425 | 'gid' => $gid, |
426 | 426 | 'practice' => 1, |
427 | 427 | ]) |
428 | - ->select('cid','name') |
|
428 | + ->select('cid', 'name') |
|
429 | 429 | ->get()->all(); |
430 | - $user_list = $this->userList($gid); |
|
430 | + $user_list=$this->userList($gid); |
|
431 | 431 | |
432 | - $memberData = []; |
|
432 | + $memberData=[]; |
|
433 | 433 | foreach ($user_list as $u) { |
434 | - $memberData[$u['uid']] = [ |
|
434 | + $memberData[$u['uid']]=[ |
|
435 | 435 | 'name' => $u['name'], |
436 | 436 | 'nick_name' => $u['nick_name'], |
437 | 437 | 'elo' => $u['ranking'], |
@@ -442,61 +442,61 @@ discard block |
||
442 | 442 | ]; |
443 | 443 | } |
444 | 444 | foreach ($allPracticeContest as $c) { |
445 | - $contestRankRaw = $contestModel->contestRank($c['cid']); |
|
446 | - foreach($contestRankRaw as $key => $contestRank){ |
|
447 | - if(isset($contestRank['remote']) && $contestRank['remote']){ |
|
445 | + $contestRankRaw=$contestModel->contestRank($c['cid']); |
|
446 | + foreach ($contestRankRaw as $key => $contestRank) { |
|
447 | + if (isset($contestRank['remote']) && $contestRank['remote']) { |
|
448 | 448 | unset($contestRankRaw[$key]); |
449 | 449 | } |
450 | 450 | } |
451 | - $contestRank = array_values($contestRankRaw); |
|
452 | - $problemsCount = DB::table('contest_problem') |
|
453 | - ->where('cid',$c['cid']) |
|
451 | + $contestRank=array_values($contestRankRaw); |
|
452 | + $problemsCount=DB::table('contest_problem') |
|
453 | + ->where('cid', $c['cid']) |
|
454 | 454 | ->count(); |
455 | - $index = 1; |
|
456 | - $rank = 1; |
|
457 | - $last_cr = []; |
|
458 | - $last_rank = 1; |
|
455 | + $index=1; |
|
456 | + $rank=1; |
|
457 | + $last_cr=[]; |
|
458 | + $last_rank=1; |
|
459 | 459 | foreach ($contestRank as $cr) { |
460 | - $last_rank = $index; |
|
461 | - if(!empty($last_cr)){ |
|
462 | - if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){ |
|
463 | - $rank = $last_rank; |
|
464 | - }else{ |
|
465 | - $rank = $index; |
|
466 | - $last_rank = $rank; |
|
460 | + $last_rank=$index; |
|
461 | + if (!empty($last_cr)) { |
|
462 | + if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) { |
|
463 | + $rank=$last_rank; |
|
464 | + } else { |
|
465 | + $rank=$index; |
|
466 | + $last_rank=$rank; |
|
467 | 467 | } |
468 | 468 | } |
469 | - if(in_array($cr['uid'],array_keys($memberData))) { |
|
470 | - $memberData[$cr['uid']]['solved_all'] += $cr['solved']; |
|
471 | - $memberData[$cr['uid']]['problem_all'] += $problemsCount; |
|
472 | - $memberData[$cr['uid']]['penalty'] += $cr['penalty']; |
|
473 | - $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [ |
|
469 | + if (in_array($cr['uid'], array_keys($memberData))) { |
|
470 | + $memberData[$cr['uid']]['solved_all']+=$cr['solved']; |
|
471 | + $memberData[$cr['uid']]['problem_all']+=$problemsCount; |
|
472 | + $memberData[$cr['uid']]['penalty']+=$cr['penalty']; |
|
473 | + $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[ |
|
474 | 474 | 'rank' => $rank, |
475 | 475 | 'solved' => $cr['solved'], |
476 | 476 | 'problems' => $problemsCount, |
477 | 477 | 'penalty' => $cr['penalty'] |
478 | 478 | ]; |
479 | 479 | } |
480 | - $last_cr = $cr; |
|
480 | + $last_cr=$cr; |
|
481 | 481 | $index++; |
482 | 482 | } |
483 | 483 | } |
484 | - $new_memberData = []; |
|
484 | + $new_memberData=[]; |
|
485 | 485 | foreach ($memberData as $uid => $data) { |
486 | - $contest_count = 0; |
|
487 | - $rank_sum = 0; |
|
486 | + $contest_count=0; |
|
487 | + $rank_sum=0; |
|
488 | 488 | foreach ($data['contest_detial'] as $cid => $c) { |
489 | - $rank_sum += $c['rank']; |
|
490 | - $contest_count += 1; |
|
489 | + $rank_sum+=$c['rank']; |
|
490 | + $contest_count+=1; |
|
491 | 491 | } |
492 | - $temp = $data; |
|
493 | - $temp['uid'] = $uid; |
|
494 | - if($contest_count != 0){ |
|
495 | - $temp['rank_ave'] = $rank_sum/$contest_count; |
|
492 | + $temp=$data; |
|
493 | + $temp['uid']=$uid; |
|
494 | + if ($contest_count!=0) { |
|
495 | + $temp['rank_ave']=$rank_sum / $contest_count; |
|
496 | 496 | } |
497 | - array_push($new_memberData,$temp); |
|
497 | + array_push($new_memberData, $temp); |
|
498 | 498 | } |
499 | - $ret = [ |
|
499 | + $ret=[ |
|
500 | 500 | 'contest_list' => $allPracticeContest, |
501 | 501 | 'member_data' => $new_memberData |
502 | 502 | ]; |
@@ -505,58 +505,58 @@ discard block |
||
505 | 505 | |
506 | 506 | public function groupMemberPracticeTagStat($gid) |
507 | 507 | { |
508 | - $tags = $this->problemTags($gid); |
|
509 | - $tag_problems = []; |
|
508 | + $tags=$this->problemTags($gid); |
|
509 | + $tag_problems=[]; |
|
510 | 510 | |
511 | - $user_list = $this->userList($gid); |
|
511 | + $user_list=$this->userList($gid); |
|
512 | 512 | foreach ($tags as $tag) { |
513 | - $tag_problems[$tag] = DB::table('problem') |
|
514 | - ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid') |
|
513 | + $tag_problems[$tag]=DB::table('problem') |
|
514 | + ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid') |
|
515 | 515 | ->where([ |
516 | 516 | 'group_problem_tag.gid' => $gid, |
517 | 517 | 'tag' => $tag |
518 | 518 | ]) |
519 | - ->select('group_problem_tag.pid as pid','pcode','title') |
|
519 | + ->select('group_problem_tag.pid as pid', 'pcode', 'title') |
|
520 | 520 | ->get()->all(); |
521 | 521 | } |
522 | - $all_problems = []; |
|
522 | + $all_problems=[]; |
|
523 | 523 | foreach ($tag_problems as &$tag_problem_set) { |
524 | 524 | foreach ($tag_problem_set as $problem) { |
525 | - $all_problems[$problem['pid']] = $problem; |
|
525 | + $all_problems[$problem['pid']]=$problem; |
|
526 | 526 | } |
527 | - $tag_problem_set = array_column($tag_problem_set,'pid'); |
|
527 | + $tag_problem_set=array_column($tag_problem_set, 'pid'); |
|
528 | 528 | } |
529 | - $submission_data = DB::table('submission') |
|
530 | - ->whereIn('pid',array_keys($all_problems)) |
|
531 | - ->whereIn('uid',array_column($user_list,'uid')) |
|
532 | - ->where('verdict','Accepted') |
|
533 | - ->select('pid','uid') |
|
529 | + $submission_data=DB::table('submission') |
|
530 | + ->whereIn('pid', array_keys($all_problems)) |
|
531 | + ->whereIn('uid', array_column($user_list, 'uid')) |
|
532 | + ->where('verdict', 'Accepted') |
|
533 | + ->select('pid', 'uid') |
|
534 | 534 | ->get()->all(); |
535 | 535 | |
536 | - $memberData = []; |
|
536 | + $memberData=[]; |
|
537 | 537 | foreach ($user_list as $member) { |
538 | - $completion = []; |
|
539 | - foreach($tag_problems as $tag => $problems) { |
|
540 | - $completion[$tag] = []; |
|
538 | + $completion=[]; |
|
539 | + foreach ($tag_problems as $tag => $problems) { |
|
540 | + $completion[$tag]=[]; |
|
541 | 541 | foreach ($problems as $problem) { |
542 | - $is_accepted = 0; |
|
542 | + $is_accepted=0; |
|
543 | 543 | foreach ($submission_data as $sd) { |
544 | - if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){ |
|
545 | - $is_accepted = 1; |
|
544 | + if ($sd['pid']==$problem && $sd['uid']==$member['uid']) { |
|
545 | + $is_accepted=1; |
|
546 | 546 | break; |
547 | 547 | } |
548 | 548 | } |
549 | - $completion[$tag][$problem] = $is_accepted; |
|
549 | + $completion[$tag][$problem]=$is_accepted; |
|
550 | 550 | } |
551 | 551 | } |
552 | - array_push($memberData,[ |
|
552 | + array_push($memberData, [ |
|
553 | 553 | 'uid' => $member['uid'], |
554 | 554 | 'name' => $member['name'], |
555 | 555 | 'nick_name' => $member['nick_name'], |
556 | 556 | 'completion' => $completion, |
557 | 557 | ]); |
558 | 558 | } |
559 | - $ret = [ |
|
559 | + $ret=[ |
|
560 | 560 | 'all_problems' => $all_problems, |
561 | 561 | 'tag_problems' => $tag_problems, |
562 | 562 | 'member_data' => $memberData |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | |
567 | 567 | public function refreshAllElo() |
568 | 568 | { |
569 | - $result = []; |
|
570 | - $gids = DB::table('group')->select('gid','name')->get()->all(); |
|
569 | + $result=[]; |
|
570 | + $gids=DB::table('group')->select('gid', 'name')->get()->all(); |
|
571 | 571 | foreach ($gids as $gid) { |
572 | - $result[$gid['gid']] = [ |
|
572 | + $result[$gid['gid']]=[ |
|
573 | 573 | 'name' => $gid['name'], |
574 | 574 | 'result' => $this->refreshElo($gid['gid']), |
575 | 575 | ]; |
@@ -580,41 +580,41 @@ discard block |
||
580 | 580 | public function refreshElo($gid) |
581 | 581 | { |
582 | 582 | DB::table('group_rated_change_log') |
583 | - ->where('gid',$gid) |
|
583 | + ->where('gid', $gid) |
|
584 | 584 | ->delete(); |
585 | 585 | DB::table('group_member') |
586 | - ->where('gid',$gid) |
|
586 | + ->where('gid', $gid) |
|
587 | 587 | ->update([ |
588 | 588 | 'ranking' => 1500 |
589 | 589 | ]); |
590 | - $contests = DB::table('contest') |
|
590 | + $contests=DB::table('contest') |
|
591 | 591 | ->where([ |
592 | 592 | 'gid' => $gid, |
593 | 593 | 'practice' => 1 |
594 | 594 | ]) |
595 | - ->where('end_time','<',date("Y-m-d H:i:s")) |
|
596 | - ->select('cid','name') |
|
595 | + ->where('end_time', '<', date("Y-m-d H:i:s")) |
|
596 | + ->select('cid', 'name') |
|
597 | 597 | ->orderBy('end_time') |
598 | 598 | ->get()->all(); |
599 | 599 | |
600 | - if(empty($contests)) { |
|
600 | + if (empty($contests)) { |
|
601 | 601 | return []; |
602 | 602 | } |
603 | - $result = []; |
|
604 | - $contestModel = new \App\Models\ContestModel(); |
|
603 | + $result=[]; |
|
604 | + $contestModel=new \App\Models\ContestModel(); |
|
605 | 605 | foreach ($contests as $contest) { |
606 | - $judge_status = $contestModel->judgeOver($contest['cid']); |
|
607 | - if($judge_status['result'] == true){ |
|
608 | - $calc = new GroupRatingCalculator($contest['cid']); |
|
606 | + $judge_status=$contestModel->judgeOver($contest['cid']); |
|
607 | + if ($judge_status['result']==true) { |
|
608 | + $calc=new GroupRatingCalculator($contest['cid']); |
|
609 | 609 | $calc->calculate(); |
610 | 610 | $calc->storage(); |
611 | - $result[] = [ |
|
611 | + $result[]=[ |
|
612 | 612 | 'ret' => 'success', |
613 | 613 | 'cid' => $contest['cid'], |
614 | 614 | 'name' => $contest['name'] |
615 | 615 | ]; |
616 | - }else{ |
|
617 | - $result[] = [ |
|
616 | + } else { |
|
617 | + $result[]=[ |
|
618 | 618 | 'ret' => 'judging', |
619 | 619 | 'cid' => $contest['cid'], |
620 | 620 | 'name' => $contest['name'], |
@@ -626,23 +626,23 @@ discard block |
||
626 | 626 | return $result; |
627 | 627 | } |
628 | 628 | |
629 | - public function getEloChangeLog($gid,$uid) |
|
629 | + public function getEloChangeLog($gid, $uid) |
|
630 | 630 | { |
631 | - $ret = DB::table('group_rated_change_log') |
|
632 | - ->join('contest','group_rated_change_log.cid','=','contest.cid') |
|
631 | + $ret=DB::table('group_rated_change_log') |
|
632 | + ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid') |
|
633 | 633 | ->where([ |
634 | 634 | 'group_rated_change_log.gid' => $gid, |
635 | 635 | 'group_rated_change_log.uid' => $uid |
636 | 636 | ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time') |
637 | 637 | ->orderBy('contest.end_time') |
638 | 638 | ->get()->all(); |
639 | - $begin = [ |
|
639 | + $begin=[ |
|
640 | 640 | 'cid' => -1, |
641 | 641 | 'name' => '', |
642 | 642 | 'ranking' => '1500', |
643 | - 'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time()) - 3600*24)), |
|
643 | + 'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)), |
|
644 | 644 | ]; |
645 | - $ret = array_prepend($ret,$begin); |
|
645 | + $ret=array_prepend($ret, $begin); |
|
646 | 646 | return $ret; |
647 | 647 | } |
648 | 648 | } |
@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | public function details($gcode) |
116 | 116 | { |
117 | 117 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
118 | - if(empty($basic_info)) return []; |
|
118 | + if(empty($basic_info)) { |
|
119 | + return []; |
|
120 | + } |
|
119 | 121 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
120 | 122 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
121 | 123 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y'); |
@@ -163,7 +165,9 @@ discard block |
||
163 | 165 | foreach ($user_list as &$u) { |
164 | 166 | $u["role_parsed"]=$this->role[$u["role"]]; |
165 | 167 | $u["role_color"]=$this->role_color[$u["role"]]; |
166 | - if(is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
168 | + if(is_null($u["sub_group"])) { |
|
169 | + $u["sub_group"]="None"; |
|
170 | + } |
|
167 | 171 | } |
168 | 172 | return $user_list; |
169 | 173 | } |
@@ -232,7 +236,7 @@ discard block |
||
232 | 236 | ->where('gid',$gid) |
233 | 237 | ->distinct() |
234 | 238 | ->get()->all(); |
235 | - }else{ |
|
239 | + } else{ |
|
236 | 240 | $tags = DB::table('group_problem_tag') |
237 | 241 | ->select('tag') |
238 | 242 | ->where('gid', $gid) |
@@ -266,7 +270,7 @@ discard block |
||
266 | 270 | foreach($problems as $key => $value){ |
267 | 271 | if($contestModel->judgeClearance($value['cid'],$user_id) != 3){ |
268 | 272 | unset($problems[$key]); |
269 | - }else{ |
|
273 | + } else{ |
|
270 | 274 | $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']); |
271 | 275 | } |
272 | 276 | } |
@@ -327,7 +331,9 @@ discard block |
||
327 | 331 | public function judgeEmailClearance($gid, $email) |
328 | 332 | { |
329 | 333 | $user=DB::table("users")->where(["email"=>$email])->first(); |
330 | - if(empty($user)) return -4; |
|
334 | + if(empty($user)) { |
|
335 | + return -4; |
|
336 | + } |
|
331 | 337 | $ret=DB::table("group_member")->where([ |
332 | 338 | "gid"=>$gid, |
333 | 339 | "uid"=>$user["id"], |
@@ -461,7 +467,7 @@ discard block |
||
461 | 467 | if(!empty($last_cr)){ |
462 | 468 | if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){ |
463 | 469 | $rank = $last_rank; |
464 | - }else{ |
|
470 | + } else{ |
|
465 | 471 | $rank = $index; |
466 | 472 | $last_rank = $rank; |
467 | 473 | } |
@@ -613,7 +619,7 @@ discard block |
||
613 | 619 | 'cid' => $contest['cid'], |
614 | 620 | 'name' => $contest['name'] |
615 | 621 | ]; |
616 | - }else{ |
|
622 | + } else{ |
|
617 | 623 | $result[] = [ |
618 | 624 | 'ret' => 'judging', |
619 | 625 | 'cid' => $contest['cid'], |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $groupModel=new GroupModel(); |
44 | 44 | $contestModel=new ContestModel(); |
45 | 45 | $basic_info=$groupModel->details($gcode); |
46 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
46 | + if (empty($basic_info)) return Redirect::route('group.index'); |
|
47 | 47 | $my_profile=$groupModel->userProfile(Auth::user()->id, $basic_info["gid"]); |
48 | 48 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
49 | 49 | $member_list=$groupModel->userList($basic_info["gid"]); |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return Response |
88 | 88 | */ |
89 | - public function analysis($gcode){ |
|
90 | - $groupModel = new GroupModel(); |
|
89 | + public function analysis($gcode) { |
|
90 | + $groupModel=new GroupModel(); |
|
91 | 91 | $basic_info=$groupModel->details($gcode); |
92 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
92 | + if (empty($basic_info)) return Redirect::route('group.index'); |
|
93 | 93 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
94 | - if($clearance < 1) return Redirect::route('group.detail',['gcode' => $gcode]); |
|
95 | - $group_info = $groupModel->details($gcode); |
|
94 | + if ($clearance<1) return Redirect::route('group.detail', ['gcode' => $gcode]); |
|
95 | + $group_info=$groupModel->details($gcode); |
|
96 | 96 | return view('group.settings.analysis', [ |
97 | 97 | 'page_title'=>"Group Analysis", |
98 | 98 | 'site_title'=>"NOJ", |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | ]); |
103 | 103 | } |
104 | 104 | |
105 | - public function analysisDownload($gcode,Request $request){ |
|
106 | - $all_data = $request->all(); |
|
107 | - $groupModel = new GroupModel(); |
|
108 | - $group_info = $groupModel->details($gcode); |
|
109 | - $mode = $all_data['mode'] ?? 'contest'; |
|
110 | - if($mode == 'contest'){ |
|
111 | - $data = $groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
105 | + public function analysisDownload($gcode, Request $request) { |
|
106 | + $all_data=$request->all(); |
|
107 | + $groupModel=new GroupModel(); |
|
108 | + $group_info=$groupModel->details($gcode); |
|
109 | + $mode=$all_data['mode'] ?? 'contest'; |
|
110 | + if ($mode=='contest') { |
|
111 | + $data=$groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
112 | 112 | return Excel::download( |
113 | 113 | new GroupAnalysisExport( |
114 | 114 | [ |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | 'percent' => $all_data['percent'] ?? false, |
122 | 122 | ] |
123 | 123 | ), |
124 | - $gcode . '_Group_Contest_Analysis.xlsx' |
|
124 | + $gcode.'_Group_Contest_Analysis.xlsx' |
|
125 | 125 | ); |
126 | - }else{ |
|
127 | - $data = $groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
126 | + } else { |
|
127 | + $data=$groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
128 | 128 | return Excel::download( |
129 | 129 | new GroupAnalysisExport( |
130 | 130 | [ |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'percent' => $all_data['percent'] ?? false, |
138 | 138 | ] |
139 | 139 | ), |
140 | - $gcode . '_Group_Tag_Analysis.xlsx' |
|
140 | + $gcode.'_Group_Tag_Analysis.xlsx' |
|
141 | 141 | ); |
142 | 142 | } |
143 | 143 | } |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | $groupModel=new GroupModel(); |
44 | 44 | $contestModel=new ContestModel(); |
45 | 45 | $basic_info=$groupModel->details($gcode); |
46 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
46 | + if(empty($basic_info)) { |
|
47 | + return Redirect::route('group.index'); |
|
48 | + } |
|
47 | 49 | $my_profile=$groupModel->userProfile(Auth::user()->id, $basic_info["gid"]); |
48 | 50 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
49 | 51 | $member_list=$groupModel->userList($basic_info["gid"]); |
@@ -89,9 +91,13 @@ discard block |
||
89 | 91 | public function analysis($gcode){ |
90 | 92 | $groupModel = new GroupModel(); |
91 | 93 | $basic_info=$groupModel->details($gcode); |
92 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
94 | + if(empty($basic_info)) { |
|
95 | + return Redirect::route('group.index'); |
|
96 | + } |
|
93 | 97 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
94 | - if($clearance < 1) return Redirect::route('group.detail',['gcode' => $gcode]); |
|
98 | + if($clearance < 1) { |
|
99 | + return Redirect::route('group.detail',['gcode' => $gcode]); |
|
100 | + } |
|
95 | 101 | $group_info = $groupModel->details($gcode); |
96 | 102 | return view('group.settings.analysis', [ |
97 | 103 | 'page_title'=>"Group Analysis", |
@@ -123,7 +129,7 @@ discard block |
||
123 | 129 | ), |
124 | 130 | $gcode . '_Group_Contest_Analysis.xlsx' |
125 | 131 | ); |
126 | - }else{ |
|
132 | + } else{ |
|
127 | 133 | $data = $groupModel->groupMemberPracticeTagStat($group_info['gid']); |
128 | 134 | return Excel::download( |
129 | 135 | new GroupAnalysisExport( |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function schedule(Schedule $schedule) |
35 | 35 | { |
36 | - $schedule->call(function () { |
|
36 | + $schedule->call(function() { |
|
37 | 37 | $babel=new Babel(); |
38 | 38 | for ($i=1; $i<=12; $i++) { |
39 | 39 | $babel->judge(); |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Judger"); |
43 | 43 | })->everyMinute()->description("Sync Judger"); |
44 | 44 | |
45 | - $schedule->call(function () { |
|
45 | + $schedule->call(function() { |
|
46 | 46 | $rankModel=new RankModel(); |
47 | 47 | $rankModel->rankList(); |
48 | 48 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated Rank"); |
49 | 49 | })->dailyAt('02:00')->description("Update Rank"); |
50 | 50 | |
51 | - $schedule->call(function () { |
|
51 | + $schedule->call(function() { |
|
52 | 52 | $siteMapModel=new SiteMapModel(); |
53 | 53 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated SiteMap"); |
54 | 54 | })->dailyAt('02:00')->description("Update SiteMap"); |
55 | 55 | |
56 | - $schedule->call(function () { |
|
56 | + $schedule->call(function() { |
|
57 | 57 | $groupModel=new GroupModel(); |
58 | 58 | $groupModel->cacheTrendingGroups(); |
59 | 59 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Cached Trending Groups"); |
60 | 60 | })->dailyAt('03:00')->description("Update Trending Groups"); |
61 | 61 | |
62 | 62 | $schedule->call(function() { |
63 | - $groupModel = new GroupModel(); |
|
64 | - $ret = $groupModel->refreshAllElo(); |
|
63 | + $groupModel=new GroupModel(); |
|
64 | + $ret=$groupModel->refreshAllElo(); |
|
65 | 65 | foreach ($ret as $gid => $group) { |
66 | - if(empty($group['result'])){ |
|
66 | + if (empty($group['result'])) { |
|
67 | 67 | Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']); |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']); |
70 | 70 | foreach ($group['result'] as $contest) { |
71 | - if($contest['ret'] == 'success'){ |
|
71 | + if ($contest['ret']=='success') { |
|
72 | 72 | Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']); |
73 | - }else{ |
|
73 | + } else { |
|
74 | 74 | Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:'); |
75 | 75 | foreach ($contest['submissions'] as $sid) { |
76 | 76 | Log::channel('group_elo')->info(' '.$sid['sid']); |
@@ -81,45 +81,45 @@ discard block |
||
81 | 81 | } |
82 | 82 | })->dailyAt('04:00')->description("Update Group Elo"); |
83 | 83 | |
84 | - $schedule->call(function () { |
|
85 | - $contestModel = new ContestModel(); |
|
86 | - $syncList = $contestModel->runningContest(); |
|
84 | + $schedule->call(function() { |
|
85 | + $contestModel=new ContestModel(); |
|
86 | + $syncList=$contestModel->runningContest(); |
|
87 | 87 | foreach ($syncList as $syncContest) { |
88 | 88 | if (!isset($syncContest['vcid'])) { |
89 | 89 | $contestRankRaw=$contestModel->contestRankCache($syncContest['cid']); |
90 | 90 | $cid=$syncContest['cid']; |
91 | 91 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
92 | 92 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
93 | - continue ; |
|
93 | + continue; |
|
94 | 94 | } |
95 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
96 | - $all_data = [ |
|
95 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
96 | + $all_data=[ |
|
97 | 97 | 'oj'=>"hdu", |
98 | 98 | 'vcid'=>$syncContest['vcid'], |
99 | 99 | 'gid'=>$syncContest['gid'], |
100 | 100 | 'cid'=>$syncContest['cid'], |
101 | 101 | ]; |
102 | - $hduSync = new $className($all_data); |
|
102 | + $hduSync=new $className($all_data); |
|
103 | 103 | $hduSync->crawlRank(); |
104 | 104 | $hduSync->crawlClarification(); |
105 | 105 | } |
106 | 106 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Remote Rank and Clarification"); |
107 | 107 | })->everyMinute()->description("Sync Remote Rank and Clarification"); |
108 | 108 | |
109 | - $schedule->call(function () { |
|
110 | - $contestModel = new ContestModel(); |
|
111 | - $syncList = $contestModel->runningContest(); |
|
109 | + $schedule->call(function() { |
|
110 | + $contestModel=new ContestModel(); |
|
111 | + $syncList=$contestModel->runningContest(); |
|
112 | 112 | foreach ($syncList as $syncContest) { |
113 | 113 | if (isset($syncContest['crawled'])) { |
114 | 114 | if (!$syncContest['crawled']) { |
115 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
116 | - $all_data = [ |
|
115 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
116 | + $all_data=[ |
|
117 | 117 | 'oj'=>"hdu", |
118 | 118 | 'vcid'=>$syncContest['vcid'], |
119 | 119 | 'gid'=>$syncContest['gid'], |
120 | 120 | 'cid'=>$syncContest['cid'], |
121 | 121 | ]; |
122 | - $hduSync = new $className($all_data); |
|
122 | + $hduSync=new $className($all_data); |
|
123 | 123 | $hduSync->scheduleCrawl(); |
124 | 124 | $contestModel->updateCrawlStatus($syncContest['cid']); |
125 | 125 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | })->everyMinute()->description("Sync Contest Problem"); |
129 | 129 | |
130 | - $schedule->call(function () { |
|
130 | + $schedule->call(function() { |
|
131 | 131 | $oidList=EloquentJudgeServerModel::column('oid'); |
132 | 132 | $babel=new Babel(); |
133 | 133 | foreach ($oidList as $oid) { |
@@ -65,12 +65,12 @@ |
||
65 | 65 | foreach ($ret as $gid => $group) { |
66 | 66 | if(empty($group['result'])){ |
67 | 67 | Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']); |
68 | - }else{ |
|
68 | + } else{ |
|
69 | 69 | Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']); |
70 | 70 | foreach ($group['result'] as $contest) { |
71 | 71 | if($contest['ret'] == 'success'){ |
72 | 72 | Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']); |
73 | - }else{ |
|
73 | + } else{ |
|
74 | 74 | Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:'); |
75 | 75 | foreach ($contest['submissions'] as $sid) { |
76 | 76 | Log::channel('group_elo')->info(' '.$sid['sid']); |