@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | ->where(['verdict'=>'Waiting']) |
| 414 | 414 | ->get() |
| 415 | 415 | ->all(); |
| 416 | - foreach($ret as &$r){ |
|
| 416 | + foreach ($ret as &$r) { |
|
| 417 | 417 | $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"]; |
| 418 | 418 | } |
| 419 | 419 | return $ret; |
@@ -431,15 +431,15 @@ discard block |
||
| 431 | 431 | if (isset($sub['verdict'])) { |
| 432 | 432 | $sub["color"]=$this->colorScheme[$sub['verdict']]; |
| 433 | 433 | } |
| 434 | - $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
| 435 | - $contestModel = new ContestModel(); |
|
| 436 | - $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
| 437 | - if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){ |
|
| 438 | - $sub['pid'] = $submission_info['pid']; |
|
| 439 | - $sub['uid'] = $submission_info['uid']; |
|
| 440 | - $sub['cid'] = $submission_info['cid']; |
|
| 441 | - $sub['sid'] = $sid; |
|
| 442 | - $contestModel->updateContestRankTable($submission_info['cid'],$sub); |
|
| 434 | + $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
| 435 | + $contestModel=new ContestModel(); |
|
| 436 | + $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
| 437 | + if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) { |
|
| 438 | + $sub['pid']=$submission_info['pid']; |
|
| 439 | + $sub['uid']=$submission_info['uid']; |
|
| 440 | + $sub['cid']=$submission_info['cid']; |
|
| 441 | + $sub['sid']=$sid; |
|
| 442 | + $contestModel->updateContestRankTable($submission_info['cid'], $sub); |
|
| 443 | 443 | } |
| 444 | 444 | return $result; |
| 445 | 445 | } |
@@ -510,15 +510,15 @@ discard block |
||
| 510 | 510 | 'desc' |
| 511 | 511 | ); |
| 512 | 512 | |
| 513 | - if($filter["pcode"]){ |
|
| 513 | + if ($filter["pcode"]) { |
|
| 514 | 514 | $paginator=$paginator->where(["pcode"=>$filter["pcode"]]); |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if($filter["result"]){ |
|
| 517 | + if ($filter["result"]) { |
|
| 518 | 518 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - if($filter["account"]){ |
|
| 521 | + if ($filter["account"]) { |
|
| 522 | 522 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
| 523 | 523 | } |
| 524 | 524 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function settings($gcode) |
| 23 | 23 | { |
| 24 | - return Redirect::route('group.settings.general', ['gcode' => $gcode]);; |
|
| 24 | + return Redirect::route('group.settings.general', ['gcode' => $gcode]); ; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function settingsReturn($gcode) |
| 33 | 33 | { |
| 34 | - return Redirect::route('group.detail', ['gcode' => $gcode]);; |
|
| 34 | + return Redirect::route('group.detail', ['gcode' => $gcode]); ; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $groupModel=new GroupModel(); |
| 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 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 48 | 48 | $member_list=$groupModel->userList($basic_info["gid"]); |
| 49 | 49 | return view('group.settings.general', [ |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return Response |
| 63 | 63 | */ |
| 64 | - public function problems($gcode){ |
|
| 65 | - $groupModel = new GroupModel(); |
|
| 66 | - $group_info = $groupModel->details($gcode); |
|
| 67 | - $problems = $groupModel->problems($group_info['gid']); |
|
| 64 | + public function problems($gcode) { |
|
| 65 | + $groupModel=new GroupModel(); |
|
| 66 | + $group_info=$groupModel->details($gcode); |
|
| 67 | + $problems=$groupModel->problems($group_info['gid']); |
|
| 68 | 68 | $basic_info=$groupModel->details($gcode); |
| 69 | 69 | return view('group.settings.problems', [ |
| 70 | 70 | 'page_title'=>"Group Problems", |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $groupModel=new GroupModel(); |
| 87 | 87 | $basic_info=$groupModel->details($gcode); |
| 88 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 88 | + if (empty($basic_info)) return Redirect::route('group.index'); |
|
| 89 | 89 | return view('group.settings.danger', [ |
| 90 | 90 | 'page_title'=>"Group Setting danger", |
| 91 | 91 | 'site_title'=>config("app.name"), |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $groupModel=new GroupModel(); |
| 105 | 105 | $contestModel=new ContestModel(); |
| 106 | 106 | $basic_info=$groupModel->details($gcode); |
| 107 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 107 | + if (empty($basic_info)) return Redirect::route('group.index'); |
|
| 108 | 108 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 109 | 109 | $member_list=$groupModel->userList($basic_info["gid"]); |
| 110 | 110 | $group_notice=$groupModel->detailNotice($gcode); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $groupModel=new GroupModel(); |
| 125 | 125 | $contestModel=new ContestModel(); |
| 126 | 126 | $basic_info=$groupModel->details($gcode); |
| 127 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 127 | + if (empty($basic_info)) return Redirect::route('group.index'); |
|
| 128 | 128 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 129 | 129 | $contest_list=$contestModel->listForSetting($basic_info["gid"]); |
| 130 | 130 | $member_list=$groupModel->userList($basic_info["gid"]); |
@@ -43,7 +43,9 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $groupModel=new GroupModel(); |
| 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 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 48 | 50 | $member_list=$groupModel->userList($basic_info["gid"]); |
| 49 | 51 | return view('group.settings.general', [ |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | { |
| 86 | 88 | $groupModel=new GroupModel(); |
| 87 | 89 | $basic_info=$groupModel->details($gcode); |
| 88 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 90 | + if(empty($basic_info)) { |
|
| 91 | + return Redirect::route('group.index'); |
|
| 92 | + } |
|
| 89 | 93 | return view('group.settings.danger', [ |
| 90 | 94 | 'page_title'=>"Group Setting danger", |
| 91 | 95 | 'site_title'=>config("app.name"), |
@@ -104,7 +108,9 @@ discard block |
||
| 104 | 108 | $groupModel=new GroupModel(); |
| 105 | 109 | $contestModel=new ContestModel(); |
| 106 | 110 | $basic_info=$groupModel->details($gcode); |
| 107 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 111 | + if(empty($basic_info)) { |
|
| 112 | + return Redirect::route('group.index'); |
|
| 113 | + } |
|
| 108 | 114 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 109 | 115 | $member_list=$groupModel->userList($basic_info["gid"]); |
| 110 | 116 | $group_notice=$groupModel->detailNotice($gcode); |
@@ -124,7 +130,9 @@ discard block |
||
| 124 | 130 | $groupModel=new GroupModel(); |
| 125 | 131 | $contestModel=new ContestModel(); |
| 126 | 132 | $basic_info=$groupModel->details($gcode); |
| 127 | - if(empty($basic_info)) return Redirect::route('group.index'); |
|
| 133 | + if(empty($basic_info)) { |
|
| 134 | + return Redirect::route('group.index'); |
|
| 135 | + } |
|
| 128 | 136 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
| 129 | 137 | $contest_list=$contestModel->listForSetting($basic_info["gid"]); |
| 130 | 138 | $member_list=$groupModel->userList($basic_info["gid"]); |
@@ -69,9 +69,13 @@ |
||
| 69 | 69 | $all_data=$request->all(); |
| 70 | 70 | |
| 71 | 71 | $groupModel=new GroupModel(); |
| 72 | - if($all_data["gcode"]=="create") return ResponseModel::err(7005); |
|
| 72 | + if($all_data["gcode"]=="create") { |
|
| 73 | + return ResponseModel::err(7005); |
|
| 74 | + } |
|
| 73 | 75 | $is_group=$groupModel->isGroup($all_data["gcode"]); |
| 74 | - if($is_group) return ResponseModel::err(7006); |
|
| 76 | + if($is_group) { |
|
| 77 | + return ResponseModel::err(7006); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp']; |
| 77 | 81 | if (!empty($request->file('img')) && $request->file('img')->isValid()) { |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | $all_data=$request->all(); |
| 70 | 70 | |
| 71 | 71 | $groupModel=new GroupModel(); |
| 72 | - if($all_data["gcode"]=="create") return ResponseModel::err(7005); |
|
| 72 | + if ($all_data["gcode"]=="create") return ResponseModel::err(7005); |
|
| 73 | 73 | $is_group=$groupModel->isGroup($all_data["gcode"]); |
| 74 | - if($is_group) return ResponseModel::err(7006); |
|
| 74 | + if ($is_group) return ResponseModel::err(7006); |
|
| 75 | 75 | |
| 76 | 76 | $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp']; |
| 77 | 77 | if (!empty($request->file('img')) && $request->file('img')->isValid()) { |
@@ -100,20 +100,20 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $groupModel=new GroupModel(); |
| 102 | 102 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 103 | - if ($clearance > 0) { |
|
| 104 | - switch($all_data['mode']){ |
|
| 103 | + if ($clearance>0) { |
|
| 104 | + switch ($all_data['mode']) { |
|
| 105 | 105 | case 'contest': |
| 106 | - $ret = $groupModel->groupMemberPracticeContestStat($all_data["gid"]); |
|
| 106 | + $ret=$groupModel->groupMemberPracticeContestStat($all_data["gid"]); |
|
| 107 | 107 | break; |
| 108 | 108 | case 'tag': |
| 109 | - $ret = $groupModel->groupMemberPracticeTagStat($all_data["gid"]); |
|
| 109 | + $ret=$groupModel->groupMemberPracticeTagStat($all_data["gid"]); |
|
| 110 | 110 | break; |
| 111 | 111 | default: |
| 112 | 112 | return ResponseModel::err(1007); |
| 113 | 113 | break; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - return ResponseModel::success(200,null,$ret); |
|
| 116 | + return ResponseModel::success(200, null, $ret); |
|
| 117 | 117 | } |
| 118 | 118 | return ResponseModel::err(7002); |
| 119 | 119 | } |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $groupModel=new GroupModel(); |
| 131 | 131 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 132 | - if($clearance <= 0){ |
|
| 132 | + if ($clearance<=0) { |
|
| 133 | 133 | return ResponseModel::err(7002); |
| 134 | 134 | } |
| 135 | - $ret = $groupModel->getEloChangeLog($all_data['gid'],$all_data['uid']); |
|
| 136 | - return ResponseModel::success(200,null,$ret); |
|
| 135 | + $ret=$groupModel->getEloChangeLog($all_data['gid'], $all_data['uid']); |
|
| 136 | + return ResponseModel::success(200, null, $ret); |
|
| 137 | 137 | } |
| 138 | 138 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $groupModel=new GroupModel(); |
| 50 | 50 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 51 | - if ($clearance < 2) { |
|
| 51 | + if ($clearance<2) { |
|
| 52 | 52 | return ResponseModel::err(7002); |
| 53 | 53 | } |
| 54 | - $tags = $groupModel->problemTags($all_data['gid'],$all_data['pid']); |
|
| 55 | - if(in_array($all_data['tag'],$tags)){ |
|
| 54 | + $tags=$groupModel->problemTags($all_data['gid'], $all_data['pid']); |
|
| 55 | + if (in_array($all_data['tag'], $tags)) { |
|
| 56 | 56 | return ResponseModel::err(7007); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $request->validate([ |
| 85 | 85 | 'gid' => 'required|string', |
| 86 | 86 | ]); |
| 87 | - $gid = $request->input('gid'); |
|
| 87 | + $gid=$request->input('gid'); |
|
| 88 | 88 | $groupModel=new GroupModel(); |
| 89 | - if($groupModel->judgeClearance($gid,Auth::user()->id) < 2) { |
|
| 89 | + if ($groupModel->judgeClearance($gid, Auth::user()->id)<2) { |
|
| 90 | 90 | return ResponseModel::err(2001); |
| 91 | 91 | } |
| 92 | 92 | $groupModel->refreshElo($gid); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | "oid"=>$oid, |
| 60 | 60 | "available"=>1, |
| 61 | 61 | "status"=>0 |
| 62 | - ])->orderBy('usage','desc')->get()->first(); |
|
| 62 | + ])->orderBy('usage', 'desc')->get()->first(); |
|
| 63 | 63 | |
| 64 | 64 | return $serverList; |
| 65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $serverList=DB::table("judge_server")->where(["oid"=>$oid])->get()->all(); |
| 70 | 70 | foreach ($serverList as &$server) { |
| 71 | - $server["status_parsed"]=is_null($server["status"])?self::$status["-1"]:self::$status[$server["status"]]; |
|
| 71 | + $server["status_parsed"]=is_null($server["status"]) ?self::$status["-1"] : self::$status[$server["status"]]; |
|
| 72 | 72 | } |
| 73 | 73 | return $serverList; |
| 74 | 74 | } |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | -if (! function_exists('babel_path')) { |
|
| 66 | +if (!function_exists('babel_path')) { |
|
| 67 | 67 | /** |
| 68 | 68 | * Get the path to the application folder. |
| 69 | 69 | * |
| 70 | 70 | * @param string $path |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | - function babel_path($path = '') |
|
| 73 | + function babel_path($path='') |
|
| 74 | 74 | { |
| 75 | 75 | return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | -if (! function_exists('glob_recursive')) { |
|
| 79 | +if (!function_exists('glob_recursive')) { |
|
| 80 | 80 | /** |
| 81 | 81 | * Find pathnames matching a pattern recursively. |
| 82 | 82 | * |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | * @param int $flags Valid flags: GLOB_MARK |
| 85 | 85 | * @return array|false an array containing the matched files/directories, an empty array if no file matched or false on error. |
| 86 | 86 | */ |
| 87 | - function glob_recursive($pattern, $flags = 0) |
|
| 87 | + function glob_recursive($pattern, $flags=0) |
|
| 88 | 88 | { |
| 89 | - $files = glob($pattern, $flags); |
|
| 90 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
| 91 | - $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 89 | + $files=glob($pattern, $flags); |
|
| 90 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
| 91 | + $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 92 | 92 | } |
| 93 | 93 | return $files; |
| 94 | 94 | } |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | function delFile($dirName) |
| 123 | 123 | { |
| 124 | 124 | if (file_exists($dirName) && $handle=opendir($dirName)) { |
| 125 | - while (false!==($item = readdir($handle))) { |
|
| 126 | - if ($item!= "." && $item != "..") { |
|
| 125 | + while (false!==($item=readdir($handle))) { |
|
| 126 | + if ($item!="." && $item!="..") { |
|
| 127 | 127 | if (file_exists($dirName.'/'.$item) && is_dir($dirName.'/'.$item)) { |
| 128 | 128 | delFile($dirName.'/'.$item); |
| 129 | 129 | } else { |
@@ -141,6 +141,6 @@ discard block |
||
| 141 | 141 | if (!function_exists('convertMarkdownToHtml')) { |
| 142 | 142 | function convertMarkdownToHtml($md) |
| 143 | 143 | { |
| 144 | - return is_string($md)?Markdown::convertToHtml($md):''; |
|
| 144 | + return is_string($md) ?Markdown::convertToHtml($md) : ''; |
|
| 145 | 145 | } |
| 146 | 146 | } |
@@ -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'], |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | foreach ($trending_groups as &$t) { |
| 58 | 58 | $t["members"]=$this->countGroupMembers($t["gid"]); |
| 59 | 59 | } |
| 60 | - usort($trending_groups, function ($a, $b) { |
|
| 60 | + usort($trending_groups, function($a, $b) { |
|
| 61 | 61 | return $b["members"]<=>$a["members"]; |
| 62 | 62 | }); |
| 63 | - Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24); |
|
| 63 | + Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function userGroups($uid) |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | public function changeGroupName($gid, $GroupName) |
| 102 | 102 | { |
| 103 | - return DB::table("group")->where('gid',$gid)->update([ |
|
| 103 | + return DB::table("group")->where('gid', $gid)->update([ |
|
| 104 | 104 | "name"=>$GroupName |
| 105 | 105 | ]); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function changeJoinPolicy($gid, $JoinPolicy){ |
|
| 109 | - return DB::table("group")->where('gid',$gid)->update([ |
|
| 108 | + public function changeJoinPolicy($gid, $JoinPolicy) { |
|
| 109 | + return DB::table("group")->where('gid', $gid)->update([ |
|
| 110 | 110 | "join_policy"=>$JoinPolicy |
| 111 | 111 | ]); |
| 112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function details($gcode) |
| 121 | 121 | { |
| 122 | 122 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
| 123 | - if(empty($basic_info)) return []; |
|
| 123 | + if (empty($basic_info)) return []; |
|
| 124 | 124 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
| 125 | 125 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
| 126 | 126 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y'); |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | public function userProfile($uid, $gid) |
| 138 | 138 | { |
| 139 | 139 | $info=DB::table("group_member") |
| 140 | - ->join('users','users.id','=','group_member.uid') |
|
| 140 | + ->join('users', 'users.id', '=', 'group_member.uid') |
|
| 141 | 141 | ->where(["gid"=>$gid, "uid"=>$uid]) |
| 142 | 142 | ->where("role", ">", 0) |
| 143 | - ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group') |
|
| 143 | + ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group') |
|
| 144 | 144 | ->first(); |
| 145 | 145 | if (!empty($info)) { |
| 146 | 146 | $info["role_parsed"]=$this->role[$info["role"]]; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | foreach ($user_list as &$u) { |
| 169 | 169 | $u["role_parsed"]=$this->role[$u["role"]]; |
| 170 | 170 | $u["role_color"]=$this->role_color[$u["role"]]; |
| 171 | - if(is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
| 171 | + if (is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
| 172 | 172 | } |
| 173 | 173 | return $user_list; |
| 174 | 174 | } |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | ])->where("role", ">", 0)->count(); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - public function problemTags($gid,$pid = -1) |
|
| 232 | + public function problemTags($gid, $pid=-1) |
|
| 233 | 233 | { |
| 234 | - if($pid == -1){ |
|
| 235 | - $tags = DB::table('group_problem_tag') |
|
| 234 | + if ($pid==-1) { |
|
| 235 | + $tags=DB::table('group_problem_tag') |
|
| 236 | 236 | ->select('tag') |
| 237 | - ->where('gid',$gid) |
|
| 237 | + ->where('gid', $gid) |
|
| 238 | 238 | ->distinct() |
| 239 | 239 | ->get()->all(); |
| 240 | - }else{ |
|
| 241 | - $tags = DB::table('group_problem_tag') |
|
| 240 | + } else { |
|
| 241 | + $tags=DB::table('group_problem_tag') |
|
| 242 | 242 | ->select('tag') |
| 243 | 243 | ->where('gid', $gid) |
| 244 | 244 | ->where('pid', $pid) |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | ->get()->all(); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - $tags_arr = []; |
|
| 250 | - if(!empty($tags)){ |
|
| 249 | + $tags_arr=[]; |
|
| 250 | + if (!empty($tags)) { |
|
| 251 | 251 | foreach ($tags as $value) { |
| 252 | - array_push($tags_arr,$value['tag']); |
|
| 252 | + array_push($tags_arr, $value['tag']); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | return $tags_arr; |
@@ -257,28 +257,28 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | public function problems($gid) |
| 259 | 259 | { |
| 260 | - $contestModel = new ContestModel(); |
|
| 261 | - $problems = DB::table('contest_problem') |
|
| 262 | - ->join('contest','contest_problem.cid', '=', 'contest.cid') |
|
| 263 | - ->join('problem','contest_problem.pid', '=', 'problem.pid' ) |
|
| 260 | + $contestModel=new ContestModel(); |
|
| 261 | + $problems=DB::table('contest_problem') |
|
| 262 | + ->join('contest', 'contest_problem.cid', '=', 'contest.cid') |
|
| 263 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
| 264 | 264 | ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title') |
| 265 | - ->where('contest.gid',$gid) |
|
| 266 | - ->where('contest.practice',1) |
|
| 267 | - ->orderBy('contest.create_time','desc') |
|
| 265 | + ->where('contest.gid', $gid) |
|
| 266 | + ->where('contest.practice', 1) |
|
| 267 | + ->orderBy('contest.create_time', 'desc') |
|
| 268 | 268 | ->distinct() |
| 269 | 269 | ->get()->all(); |
| 270 | - $user_id = Auth::user()->id; |
|
| 271 | - foreach($problems as $key => $value){ |
|
| 272 | - if($contestModel->judgeClearance($value['cid'],$user_id) != 3){ |
|
| 270 | + $user_id=Auth::user()->id; |
|
| 271 | + foreach ($problems as $key => $value) { |
|
| 272 | + if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) { |
|
| 273 | 273 | unset($problems[$key]); |
| 274 | - }else{ |
|
| 275 | - $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']); |
|
| 274 | + } else { |
|
| 275 | + $problems[$key]['tags']=$this->problemTags($gid, $value['pid']); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | return $problems; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public function problemAddTag($gid,$pid,$tag) |
|
| 281 | + public function problemAddTag($gid, $pid, $tag) |
|
| 282 | 282 | { |
| 283 | 283 | return DB::table("group_problem_tag")->insert([ |
| 284 | 284 | "gid"=>$gid, |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | ]); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public function problemRemoveTag($gid,$pid,$tag) |
|
| 290 | + public function problemRemoveTag($gid, $pid, $tag) |
|
| 291 | 291 | { |
| 292 | 292 | return DB::table("group_problem_tag")->where([ |
| 293 | 293 | "gid"=>$gid, |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | public function judgeEmailClearance($gid, $email) |
| 333 | 333 | { |
| 334 | 334 | $user=DB::table("users")->where(["email"=>$email])->first(); |
| 335 | - if(empty($user)) return -4; |
|
| 335 | + if (empty($user)) return -4; |
|
| 336 | 336 | $ret=DB::table("group_member")->where([ |
| 337 | 337 | "gid"=>$gid, |
| 338 | 338 | "uid"=>$user["id"], |
@@ -423,20 +423,20 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | public function groupMemberPracticeContestStat($gid) |
| 425 | 425 | { |
| 426 | - $contestModel = new ContestModel(); |
|
| 426 | + $contestModel=new ContestModel(); |
|
| 427 | 427 | |
| 428 | - $allPracticeContest = DB::table('contest') |
|
| 428 | + $allPracticeContest=DB::table('contest') |
|
| 429 | 429 | ->where([ |
| 430 | 430 | 'gid' => $gid, |
| 431 | 431 | 'practice' => 1, |
| 432 | 432 | ]) |
| 433 | - ->select('cid','name') |
|
| 433 | + ->select('cid', 'name') |
|
| 434 | 434 | ->get()->all(); |
| 435 | - $user_list = $this->userList($gid); |
|
| 435 | + $user_list=$this->userList($gid); |
|
| 436 | 436 | |
| 437 | - $memberData = []; |
|
| 437 | + $memberData=[]; |
|
| 438 | 438 | foreach ($user_list as $u) { |
| 439 | - $memberData[$u['uid']] = [ |
|
| 439 | + $memberData[$u['uid']]=[ |
|
| 440 | 440 | 'name' => $u['name'], |
| 441 | 441 | 'nick_name' => $u['nick_name'], |
| 442 | 442 | 'elo' => $u['ranking'], |
@@ -447,61 +447,61 @@ discard block |
||
| 447 | 447 | ]; |
| 448 | 448 | } |
| 449 | 449 | foreach ($allPracticeContest as $c) { |
| 450 | - $contestRankRaw = $contestModel->contestRank($c['cid']); |
|
| 451 | - foreach($contestRankRaw as $key => $contestRank){ |
|
| 452 | - if(isset($contestRank['remote']) && $contestRank['remote']){ |
|
| 450 | + $contestRankRaw=$contestModel->contestRank($c['cid']); |
|
| 451 | + foreach ($contestRankRaw as $key => $contestRank) { |
|
| 452 | + if (isset($contestRank['remote']) && $contestRank['remote']) { |
|
| 453 | 453 | unset($contestRankRaw[$key]); |
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | - $contestRank = array_values($contestRankRaw); |
|
| 457 | - $problemsCount = DB::table('contest_problem') |
|
| 458 | - ->where('cid',$c['cid']) |
|
| 456 | + $contestRank=array_values($contestRankRaw); |
|
| 457 | + $problemsCount=DB::table('contest_problem') |
|
| 458 | + ->where('cid', $c['cid']) |
|
| 459 | 459 | ->count(); |
| 460 | - $index = 1; |
|
| 461 | - $rank = 1; |
|
| 462 | - $last_cr = []; |
|
| 463 | - $last_rank = 1; |
|
| 460 | + $index=1; |
|
| 461 | + $rank=1; |
|
| 462 | + $last_cr=[]; |
|
| 463 | + $last_rank=1; |
|
| 464 | 464 | foreach ($contestRank as $cr) { |
| 465 | - $last_rank = $index; |
|
| 466 | - if(!empty($last_cr)){ |
|
| 467 | - if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){ |
|
| 468 | - $rank = $last_rank; |
|
| 469 | - }else{ |
|
| 470 | - $rank = $index; |
|
| 471 | - $last_rank = $rank; |
|
| 465 | + $last_rank=$index; |
|
| 466 | + if (!empty($last_cr)) { |
|
| 467 | + if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) { |
|
| 468 | + $rank=$last_rank; |
|
| 469 | + } else { |
|
| 470 | + $rank=$index; |
|
| 471 | + $last_rank=$rank; |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | - if(in_array($cr['uid'],array_keys($memberData))) { |
|
| 475 | - $memberData[$cr['uid']]['solved_all'] += $cr['solved']; |
|
| 476 | - $memberData[$cr['uid']]['problem_all'] += $problemsCount; |
|
| 477 | - $memberData[$cr['uid']]['penalty'] += $cr['penalty']; |
|
| 478 | - $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [ |
|
| 474 | + if (in_array($cr['uid'], array_keys($memberData))) { |
|
| 475 | + $memberData[$cr['uid']]['solved_all']+=$cr['solved']; |
|
| 476 | + $memberData[$cr['uid']]['problem_all']+=$problemsCount; |
|
| 477 | + $memberData[$cr['uid']]['penalty']+=$cr['penalty']; |
|
| 478 | + $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[ |
|
| 479 | 479 | 'rank' => $rank, |
| 480 | 480 | 'solved' => $cr['solved'], |
| 481 | 481 | 'problems' => $problemsCount, |
| 482 | 482 | 'penalty' => $cr['penalty'] |
| 483 | 483 | ]; |
| 484 | 484 | } |
| 485 | - $last_cr = $cr; |
|
| 485 | + $last_cr=$cr; |
|
| 486 | 486 | $index++; |
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | - $new_memberData = []; |
|
| 489 | + $new_memberData=[]; |
|
| 490 | 490 | foreach ($memberData as $uid => $data) { |
| 491 | - $contest_count = 0; |
|
| 492 | - $rank_sum = 0; |
|
| 491 | + $contest_count=0; |
|
| 492 | + $rank_sum=0; |
|
| 493 | 493 | foreach ($data['contest_detial'] as $cid => $c) { |
| 494 | - $rank_sum += $c['rank']; |
|
| 495 | - $contest_count += 1; |
|
| 494 | + $rank_sum+=$c['rank']; |
|
| 495 | + $contest_count+=1; |
|
| 496 | 496 | } |
| 497 | - $temp = $data; |
|
| 498 | - $temp['uid'] = $uid; |
|
| 499 | - if($contest_count != 0){ |
|
| 500 | - $temp['rank_ave'] = $rank_sum/$contest_count; |
|
| 497 | + $temp=$data; |
|
| 498 | + $temp['uid']=$uid; |
|
| 499 | + if ($contest_count!=0) { |
|
| 500 | + $temp['rank_ave']=$rank_sum / $contest_count; |
|
| 501 | 501 | } |
| 502 | - array_push($new_memberData,$temp); |
|
| 502 | + array_push($new_memberData, $temp); |
|
| 503 | 503 | } |
| 504 | - $ret = [ |
|
| 504 | + $ret=[ |
|
| 505 | 505 | 'contest_list' => $allPracticeContest, |
| 506 | 506 | 'member_data' => $new_memberData |
| 507 | 507 | ]; |
@@ -510,58 +510,58 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | public function groupMemberPracticeTagStat($gid) |
| 512 | 512 | { |
| 513 | - $tags = $this->problemTags($gid); |
|
| 514 | - $tag_problems = []; |
|
| 513 | + $tags=$this->problemTags($gid); |
|
| 514 | + $tag_problems=[]; |
|
| 515 | 515 | |
| 516 | - $user_list = $this->userList($gid); |
|
| 516 | + $user_list=$this->userList($gid); |
|
| 517 | 517 | foreach ($tags as $tag) { |
| 518 | - $tag_problems[$tag] = DB::table('problem') |
|
| 519 | - ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid') |
|
| 518 | + $tag_problems[$tag]=DB::table('problem') |
|
| 519 | + ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid') |
|
| 520 | 520 | ->where([ |
| 521 | 521 | 'group_problem_tag.gid' => $gid, |
| 522 | 522 | 'tag' => $tag |
| 523 | 523 | ]) |
| 524 | - ->select('group_problem_tag.pid as pid','pcode','title') |
|
| 524 | + ->select('group_problem_tag.pid as pid', 'pcode', 'title') |
|
| 525 | 525 | ->get()->all(); |
| 526 | 526 | } |
| 527 | - $all_problems = []; |
|
| 527 | + $all_problems=[]; |
|
| 528 | 528 | foreach ($tag_problems as &$tag_problem_set) { |
| 529 | 529 | foreach ($tag_problem_set as $problem) { |
| 530 | - $all_problems[$problem['pid']] = $problem; |
|
| 530 | + $all_problems[$problem['pid']]=$problem; |
|
| 531 | 531 | } |
| 532 | - $tag_problem_set = array_column($tag_problem_set,'pid'); |
|
| 532 | + $tag_problem_set=array_column($tag_problem_set, 'pid'); |
|
| 533 | 533 | } |
| 534 | - $submission_data = DB::table('submission') |
|
| 535 | - ->whereIn('pid',array_keys($all_problems)) |
|
| 536 | - ->whereIn('uid',array_column($user_list,'uid')) |
|
| 537 | - ->where('verdict','Accepted') |
|
| 538 | - ->select('pid','uid') |
|
| 534 | + $submission_data=DB::table('submission') |
|
| 535 | + ->whereIn('pid', array_keys($all_problems)) |
|
| 536 | + ->whereIn('uid', array_column($user_list, 'uid')) |
|
| 537 | + ->where('verdict', 'Accepted') |
|
| 538 | + ->select('pid', 'uid') |
|
| 539 | 539 | ->get()->all(); |
| 540 | 540 | |
| 541 | - $memberData = []; |
|
| 541 | + $memberData=[]; |
|
| 542 | 542 | foreach ($user_list as $member) { |
| 543 | - $completion = []; |
|
| 544 | - foreach($tag_problems as $tag => $problems) { |
|
| 545 | - $completion[$tag] = []; |
|
| 543 | + $completion=[]; |
|
| 544 | + foreach ($tag_problems as $tag => $problems) { |
|
| 545 | + $completion[$tag]=[]; |
|
| 546 | 546 | foreach ($problems as $problem) { |
| 547 | - $is_accepted = 0; |
|
| 547 | + $is_accepted=0; |
|
| 548 | 548 | foreach ($submission_data as $sd) { |
| 549 | - if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){ |
|
| 550 | - $is_accepted = 1; |
|
| 549 | + if ($sd['pid']==$problem && $sd['uid']==$member['uid']) { |
|
| 550 | + $is_accepted=1; |
|
| 551 | 551 | break; |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | - $completion[$tag][$problem] = $is_accepted; |
|
| 554 | + $completion[$tag][$problem]=$is_accepted; |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | - array_push($memberData,[ |
|
| 557 | + array_push($memberData, [ |
|
| 558 | 558 | 'uid' => $member['uid'], |
| 559 | 559 | 'name' => $member['name'], |
| 560 | 560 | 'nick_name' => $member['nick_name'], |
| 561 | 561 | 'completion' => $completion, |
| 562 | 562 | ]); |
| 563 | 563 | } |
| 564 | - $ret = [ |
|
| 564 | + $ret=[ |
|
| 565 | 565 | 'all_problems' => $all_problems, |
| 566 | 566 | 'tag_problems' => $tag_problems, |
| 567 | 567 | 'member_data' => $memberData |
@@ -571,10 +571,10 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | public function refreshAllElo() |
| 573 | 573 | { |
| 574 | - $result = []; |
|
| 575 | - $gids = DB::table('group')->select('gid','name')->get()->all(); |
|
| 574 | + $result=[]; |
|
| 575 | + $gids=DB::table('group')->select('gid', 'name')->get()->all(); |
|
| 576 | 576 | foreach ($gids as $gid) { |
| 577 | - $result[$gid['gid']] = [ |
|
| 577 | + $result[$gid['gid']]=[ |
|
| 578 | 578 | 'name' => $gid['name'], |
| 579 | 579 | 'result' => $this->refreshElo($gid['gid']), |
| 580 | 580 | ]; |
@@ -585,41 +585,41 @@ discard block |
||
| 585 | 585 | public function refreshElo($gid) |
| 586 | 586 | { |
| 587 | 587 | DB::table('group_rated_change_log') |
| 588 | - ->where('gid',$gid) |
|
| 588 | + ->where('gid', $gid) |
|
| 589 | 589 | ->delete(); |
| 590 | 590 | DB::table('group_member') |
| 591 | - ->where('gid',$gid) |
|
| 591 | + ->where('gid', $gid) |
|
| 592 | 592 | ->update([ |
| 593 | 593 | 'ranking' => 1500 |
| 594 | 594 | ]); |
| 595 | - $contests = DB::table('contest') |
|
| 595 | + $contests=DB::table('contest') |
|
| 596 | 596 | ->where([ |
| 597 | 597 | 'gid' => $gid, |
| 598 | 598 | 'practice' => 1 |
| 599 | 599 | ]) |
| 600 | - ->where('end_time','<',date("Y-m-d H:i:s")) |
|
| 601 | - ->select('cid','name') |
|
| 600 | + ->where('end_time', '<', date("Y-m-d H:i:s")) |
|
| 601 | + ->select('cid', 'name') |
|
| 602 | 602 | ->orderBy('end_time') |
| 603 | 603 | ->get()->all(); |
| 604 | 604 | |
| 605 | - if(empty($contests)) { |
|
| 605 | + if (empty($contests)) { |
|
| 606 | 606 | return []; |
| 607 | 607 | } |
| 608 | - $result = []; |
|
| 609 | - $contestModel = new ContestModel(); |
|
| 608 | + $result=[]; |
|
| 609 | + $contestModel=new ContestModel(); |
|
| 610 | 610 | foreach ($contests as $contest) { |
| 611 | - $judge_status = $contestModel->judgeOver($contest['cid']); |
|
| 612 | - if($judge_status['result'] == true){ |
|
| 613 | - $calc = new GroupRatingCalculator($contest['cid']); |
|
| 611 | + $judge_status=$contestModel->judgeOver($contest['cid']); |
|
| 612 | + if ($judge_status['result']==true) { |
|
| 613 | + $calc=new GroupRatingCalculator($contest['cid']); |
|
| 614 | 614 | $calc->calculate(); |
| 615 | 615 | $calc->storage(); |
| 616 | - $result[] = [ |
|
| 616 | + $result[]=[ |
|
| 617 | 617 | 'ret' => 'success', |
| 618 | 618 | 'cid' => $contest['cid'], |
| 619 | 619 | 'name' => $contest['name'] |
| 620 | 620 | ]; |
| 621 | - }else{ |
|
| 622 | - $result[] = [ |
|
| 621 | + } else { |
|
| 622 | + $result[]=[ |
|
| 623 | 623 | 'ret' => 'judging', |
| 624 | 624 | 'cid' => $contest['cid'], |
| 625 | 625 | 'name' => $contest['name'], |
@@ -631,23 +631,23 @@ discard block |
||
| 631 | 631 | return $result; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - public function getEloChangeLog($gid,$uid) |
|
| 634 | + public function getEloChangeLog($gid, $uid) |
|
| 635 | 635 | { |
| 636 | - $ret = DB::table('group_rated_change_log') |
|
| 637 | - ->join('contest','group_rated_change_log.cid','=','contest.cid') |
|
| 636 | + $ret=DB::table('group_rated_change_log') |
|
| 637 | + ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid') |
|
| 638 | 638 | ->where([ |
| 639 | 639 | 'group_rated_change_log.gid' => $gid, |
| 640 | 640 | 'group_rated_change_log.uid' => $uid |
| 641 | 641 | ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time') |
| 642 | 642 | ->orderBy('contest.end_time') |
| 643 | 643 | ->get()->all(); |
| 644 | - $begin = [ |
|
| 644 | + $begin=[ |
|
| 645 | 645 | 'cid' => -1, |
| 646 | 646 | 'name' => '', |
| 647 | 647 | 'ranking' => '1500', |
| 648 | - 'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time()) - 3600*24)), |
|
| 648 | + 'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)), |
|
| 649 | 649 | ]; |
| 650 | - $ret = array_prepend($ret,$begin); |
|
| 650 | + $ret=array_prepend($ret, $begin); |
|
| 651 | 651 | return $ret; |
| 652 | 652 | } |
| 653 | 653 | } |
@@ -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']); |