@@ -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); |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | |
179 | 179 | private function inteliAudit($uid, $content) |
180 | 180 | { |
181 | - if (strpos($content, '```')!==false){ |
|
181 | + if (strpos($content, '```')!==false) { |
|
182 | 182 | $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first(); |
183 | - if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){ |
|
183 | + if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) { |
|
184 | 184 | return 1; |
185 | 185 | } |
186 | 186 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | |
431 | 431 | if (!empty($data["sample"])) { |
432 | 432 | foreach ($data["sample"] as $d) { |
433 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
433 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
434 | 434 | DB::table("problem_sample")->insert([ |
435 | 435 | 'pid'=>$pid, |
436 | 436 | 'sample_input'=>$d['sample_input'], |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | |
477 | 477 | if (!empty($data["sample"])) { |
478 | 478 | foreach ($data["sample"] as $d) { |
479 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
479 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
480 | 480 | DB::table("problem_sample")->insert([ |
481 | 481 | 'pid'=>$pid, |
482 | 482 | 'sample_input'=>$d['sample_input'], |
@@ -430,7 +430,9 @@ discard block |
||
430 | 430 | |
431 | 431 | if (!empty($data["sample"])) { |
432 | 432 | foreach ($data["sample"] as $d) { |
433 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
433 | + if(!isset($d['sample_note'])) { |
|
434 | + $d['sample_note']=null; |
|
435 | + } |
|
434 | 436 | DB::table("problem_sample")->insert([ |
435 | 437 | 'pid'=>$pid, |
436 | 438 | 'sample_input'=>$d['sample_input'], |
@@ -476,7 +478,9 @@ discard block |
||
476 | 478 | |
477 | 479 | if (!empty($data["sample"])) { |
478 | 480 | foreach ($data["sample"] as $d) { |
479 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
481 | + if(!isset($d['sample_note'])) { |
|
482 | + $d['sample_note']=null; |
|
483 | + } |
|
480 | 484 | DB::table("problem_sample")->insert([ |
481 | 485 | 'pid'=>$pid, |
482 | 486 | 'sample_input'=>$d['sample_input'], |
@@ -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 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | ]; |
107 | 107 | } |
108 | 108 | |
109 | - $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
110 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
109 | + $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
110 | + if (empty($editor_left_width)) $editor_left_width='40'; |
|
111 | 111 | |
112 | 112 | return view('contest.board.editor', [ |
113 | 113 | 'page_title'=>"Problem Detail", |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | |
152 | 152 | // To determine the ranking |
153 | 153 | foreach ($contestRank as $i => &$r) { |
154 | - if($i != 0) { |
|
155 | - if($r['score'] == $contestRank[$i-1]['score'] && $r['penalty'] == $contestRank[$i-1]['penalty']){ |
|
156 | - $r['rank'] = $contestRank[$i-1]['rank']; |
|
157 | - }else{ |
|
158 | - $r['rank'] = $i + 1; |
|
154 | + if ($i!=0) { |
|
155 | + if ($r['score']==$contestRank[$i-1]['score'] && $r['penalty']==$contestRank[$i-1]['penalty']) { |
|
156 | + $r['rank']=$contestRank[$i-1]['rank']; |
|
157 | + } else { |
|
158 | + $r['rank']=$i+1; |
|
159 | 159 | } |
160 | - }else{ |
|
161 | - $r['rank'] = 1; |
|
160 | + } else { |
|
161 | + $r['rank']=1; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | $rankFrozen=$contestModel->isFrozen($cid); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ]); |
279 | 279 | } |
280 | 280 | |
281 | - public function analysis($cid){ |
|
281 | + public function analysis($cid) { |
|
282 | 282 | $contestModel=new ContestModel(); |
283 | 283 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
284 | 284 | if (!$clearance) { |
@@ -107,7 +107,9 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
110 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
110 | + if(empty($editor_left_width)) { |
|
111 | + $editor_left_width='40'; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | return view('contest.board.editor', [ |
113 | 115 | 'page_title'=>"Problem Detail", |
@@ -154,10 +156,10 @@ discard block |
||
154 | 156 | if($i != 0) { |
155 | 157 | if($r['score'] == $contestRank[$i-1]['score'] && $r['penalty'] == $contestRank[$i-1]['penalty']){ |
156 | 158 | $r['rank'] = $contestRank[$i-1]['rank']; |
157 | - }else{ |
|
159 | + } else{ |
|
158 | 160 | $r['rank'] = $i + 1; |
159 | 161 | } |
160 | - }else{ |
|
162 | + } else{ |
|
161 | 163 | $r['rank'] = 1; |
162 | 164 | } |
163 | 165 | } |
@@ -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']); |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | public function login($all_data) |
20 | 20 | { |
21 | - if(isset($all_data["url"])) $url = $all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = 'false'; |
|
25 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
21 | + if (isset($all_data["url"])) $url=$all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret='false'; |
|
25 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
26 | 26 | |
27 | 27 | $datapost=curl_init(); |
28 | 28 | $headers=array("Expect:"); |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | public function grab_page($all_data) |
56 | 56 | { |
57 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | - if(isset($all_data["headers"])) $headers = $all_data["headers"]; else $headers = []; |
|
60 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
61 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = false; |
|
62 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
57 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | + if (isset($all_data["headers"])) $headers=$all_data["headers"]; else $headers=[]; |
|
60 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
61 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=false; |
|
62 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
63 | 63 | |
64 | 64 | $handle=urlencode($handle); |
65 | 65 | |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | |
87 | 87 | public function post_data($all_data) |
88 | 88 | { |
89 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = false; |
|
93 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = true; |
|
94 | - if(isset($all_data["returnHeader"])) $returnHeader = $all_data["returnHeader"]; else $returnHeader = true; |
|
95 | - if(isset($all_data["postJson"])) $postJson = $all_data["postJson"]; else $postJson = false; |
|
96 | - if(isset($all_data["extraHeaders"])) $extraHeaders = $all_data["extraHeaders"]; else $extraHeaders = []; |
|
97 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
98 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
89 | + if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | + if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | + if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | + if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret=false; |
|
93 | + if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=true; |
|
94 | + if (isset($all_data["returnHeader"])) $returnHeader=$all_data["returnHeader"]; else $returnHeader=true; |
|
95 | + if (isset($all_data["postJson"])) $postJson=$all_data["postJson"]; else $postJson=false; |
|
96 | + if (isset($all_data["extraHeaders"])) $extraHeaders=$all_data["extraHeaders"]; else $extraHeaders=[]; |
|
97 | + if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
98 | + if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
99 | 99 | |
100 | 100 | $handle=urlencode($handle); |
101 | 101 |
@@ -18,11 +18,31 @@ discard block |
||
18 | 18 | |
19 | 19 | public function login($all_data) |
20 | 20 | { |
21 | - if(isset($all_data["url"])) $url = $all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = 'false'; |
|
25 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
21 | + if(isset($all_data["url"])) { |
|
22 | + $url = $all_data["url"]; |
|
23 | + } else { |
|
24 | + throw new Exception("url is not exist in all_data"); |
|
25 | + } |
|
26 | + if(isset($all_data["data"])) { |
|
27 | + $data = $all_data["data"]; |
|
28 | + } else { |
|
29 | + throw new Exception("data is not exist in all_data"); |
|
30 | + } |
|
31 | + if(isset($all_data["oj"])) { |
|
32 | + $oj = $all_data["oj"]; |
|
33 | + } else { |
|
34 | + throw new Exception("oj is not exist in all_data"); |
|
35 | + } |
|
36 | + if(isset($all_data["ret"])) { |
|
37 | + $ret = $all_data["ret"]; |
|
38 | + } else { |
|
39 | + $ret = 'false'; |
|
40 | + } |
|
41 | + if(isset($all_data["handle"])) { |
|
42 | + $handle = $all_data["handle"]; |
|
43 | + } else { |
|
44 | + $handle = "default"; |
|
45 | + } |
|
26 | 46 | |
27 | 47 | $datapost=curl_init(); |
28 | 48 | $headers=array("Expect:"); |
@@ -54,12 +74,36 @@ discard block |
||
54 | 74 | |
55 | 75 | public function grab_page($all_data) |
56 | 76 | { |
57 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | - if(isset($all_data["headers"])) $headers = $all_data["headers"]; else $headers = []; |
|
60 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
61 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = false; |
|
62 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
77 | + if(isset($all_data["site"])) { |
|
78 | + $site = $all_data["site"]; |
|
79 | + } else { |
|
80 | + throw new Exception("site is not exist in all_data"); |
|
81 | + } |
|
82 | + if(isset($all_data["oj"])) { |
|
83 | + $oj = $all_data["oj"]; |
|
84 | + } else { |
|
85 | + throw new Exception("oj is not exist in all_data"); |
|
86 | + } |
|
87 | + if(isset($all_data["headers"])) { |
|
88 | + $headers = $all_data["headers"]; |
|
89 | + } else { |
|
90 | + $headers = []; |
|
91 | + } |
|
92 | + if(isset($all_data["handle"])) { |
|
93 | + $handle = $all_data["handle"]; |
|
94 | + } else { |
|
95 | + $handle = "default"; |
|
96 | + } |
|
97 | + if(isset($all_data["follow"])) { |
|
98 | + $follow = $all_data["follow"]; |
|
99 | + } else { |
|
100 | + $follow = false; |
|
101 | + } |
|
102 | + if(isset($all_data["vcid"])) { |
|
103 | + $vcid = $all_data["vcid"]."_"; |
|
104 | + } else { |
|
105 | + $vcid = ""; |
|
106 | + } |
|
63 | 107 | |
64 | 108 | $handle=urlencode($handle); |
65 | 109 | |
@@ -86,16 +130,56 @@ discard block |
||
86 | 130 | |
87 | 131 | public function post_data($all_data) |
88 | 132 | { |
89 | - if(isset($all_data["site"])) $site = $all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | - if(isset($all_data["data"])) $data = $all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | - if(isset($all_data["oj"])) $oj = $all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | - if(isset($all_data["ret"])) $ret = $all_data["ret"]; else $ret = false; |
|
93 | - if(isset($all_data["follow"])) $follow = $all_data["follow"]; else $follow = true; |
|
94 | - if(isset($all_data["returnHeader"])) $returnHeader = $all_data["returnHeader"]; else $returnHeader = true; |
|
95 | - if(isset($all_data["postJson"])) $postJson = $all_data["postJson"]; else $postJson = false; |
|
96 | - if(isset($all_data["extraHeaders"])) $extraHeaders = $all_data["extraHeaders"]; else $extraHeaders = []; |
|
97 | - if(isset($all_data["handle"])) $handle = $all_data["handle"]; else $handle = "default"; |
|
98 | - if(isset($all_data["vcid"])) $vcid = $all_data["vcid"]."_"; else $vcid = ""; |
|
133 | + if(isset($all_data["site"])) { |
|
134 | + $site = $all_data["site"]; |
|
135 | + } else { |
|
136 | + throw new Exception("site is not exist in all_data"); |
|
137 | + } |
|
138 | + if(isset($all_data["data"])) { |
|
139 | + $data = $all_data["data"]; |
|
140 | + } else { |
|
141 | + throw new Exception("data is not exist in all_data"); |
|
142 | + } |
|
143 | + if(isset($all_data["oj"])) { |
|
144 | + $oj = $all_data["oj"]; |
|
145 | + } else { |
|
146 | + throw new Exception("oj is not exist in all_data"); |
|
147 | + } |
|
148 | + if(isset($all_data["ret"])) { |
|
149 | + $ret = $all_data["ret"]; |
|
150 | + } else { |
|
151 | + $ret = false; |
|
152 | + } |
|
153 | + if(isset($all_data["follow"])) { |
|
154 | + $follow = $all_data["follow"]; |
|
155 | + } else { |
|
156 | + $follow = true; |
|
157 | + } |
|
158 | + if(isset($all_data["returnHeader"])) { |
|
159 | + $returnHeader = $all_data["returnHeader"]; |
|
160 | + } else { |
|
161 | + $returnHeader = true; |
|
162 | + } |
|
163 | + if(isset($all_data["postJson"])) { |
|
164 | + $postJson = $all_data["postJson"]; |
|
165 | + } else { |
|
166 | + $postJson = false; |
|
167 | + } |
|
168 | + if(isset($all_data["extraHeaders"])) { |
|
169 | + $extraHeaders = $all_data["extraHeaders"]; |
|
170 | + } else { |
|
171 | + $extraHeaders = []; |
|
172 | + } |
|
173 | + if(isset($all_data["handle"])) { |
|
174 | + $handle = $all_data["handle"]; |
|
175 | + } else { |
|
176 | + $handle = "default"; |
|
177 | + } |
|
178 | + if(isset($all_data["vcid"])) { |
|
179 | + $vcid = $all_data["vcid"]."_"; |
|
180 | + } else { |
|
181 | + $vcid = ""; |
|
182 | + } |
|
99 | 183 | |
100 | 184 | $handle=urlencode($handle); |
101 | 185 |