Passed
Branch dev (b46dca)
by John
04:11
created
app/Models/SubmissionModel.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/SearchController.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,34 +23,34 @@
 block discarded – undo
23 23
         if (!$request->has('search_key')) {
24 24
             return ResponseModel::err(1003);
25 25
         }
26
-        $key  = $request->input('search_key');
27
-        $all_result  = [];
28
-        $search_from = [
26
+        $key=$request->input('search_key');
27
+        $all_result=[];
28
+        $search_from=[
29 29
             'users'         => \App\Models\Search\UserSearchModel::class,
30 30
             'problems'      => \App\Models\Search\ProblemSearchModel::class,
31 31
             'contests'      => \App\Models\Search\ContestSearchModel::class,
32 32
             'groups'        => \App\Models\Search\GroupSearchModel::class,
33 33
         ];
34 34
         foreach ($search_from as $name => $model_class) {
35
-            if(class_exists($model_class)){
36
-                $model = new $model_class();
37
-                if(!method_exists($model,'search')){
38
-                    $all_result[$name] = [
35
+            if (class_exists($model_class)) {
36
+                $model=new $model_class();
37
+                if (!method_exists($model, 'search')) {
38
+                    $all_result[$name]=[
39 39
                         'code' => -1,
40 40
                         'msg' => 'cannot find search method in '.$model_class
41 41
                     ];
42 42
                     continue;
43 43
                 }
44
-                $result = $model->search($key);
45
-                $all_result[$name] = $result;
46
-            }else{
47
-                $all_result[$name] = [
44
+                $result=$model->search($key);
45
+                $all_result[$name]=$result;
46
+            } else {
47
+                $all_result[$name]=[
48 48
                     'code' => -1,
49 49
                     'msg' => 'cannot find class named '.$model_class
50
-                ];;
50
+                ]; ;
51 51
                 continue;
52 52
             }
53 53
         }
54
-        return ResponseModel::success(200,'Successful',$all_result);
54
+        return ResponseModel::success(200, 'Successful', $all_result);
55 55
     }
56 56
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
                 }
44 44
                 $result = $model->search($key);
45 45
                 $all_result[$name] = $result;
46
-            }else{
46
+            } else{
47 47
                 $all_result[$name] = [
48 48
                     'code' => -1,
49 49
                     'msg' => 'cannot find class named '.$model_class
Please login to merge, or discard this patch.
app/Models/JudgerModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
     {
92 92
         $serverList=DB::table("judge_server")->where(["oid"=>$oid])->get()->all();
93 93
         foreach ($serverList as &$server) {
94
-            $server["status_parsed"]=is_null($server["status"])?self::$status["-1"]:self::$status[$server["status"]];
94
+            $server["status_parsed"]=is_null($server["status"]) ?self::$status["-1"] : self::$status[$server["status"]];
95 95
         }
96 96
         return $serverList;
97 97
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/ProblemController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         if (empty($basic)) {
111 111
             return ResponseModel::err(3001);
112 112
         }
113
-        $ret=$problemModel->addSolution($pid,Auth::user()->id,$content);
114
-        return $ret?ResponseModel::success(200):ResponseModel::err(3003);
113
+        $ret=$problemModel->addSolution($pid, Auth::user()->id, $content);
114
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3003);
115 115
     }
116 116
     /**
117 117
      * The Ajax Problem Solution Discussion Update.
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
         $problemModel=new ProblemModel();
127 127
         $psoid=$all_data["psoid"];
128 128
         $content=$all_data["content"];
129
-        $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content);
130
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
129
+        $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content);
130
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
131 131
     }
132 132
     /**
133 133
      * The Ajax Problem Solution Discussion Delete.
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
         $all_data=$request->all();
142 142
         $problemModel=new ProblemModel();
143 143
         $psoid=$all_data["psoid"];
144
-        $ret=$problemModel->removeSolution($psoid,Auth::user()->id);
145
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
144
+        $ret=$problemModel->removeSolution($psoid, Auth::user()->id);
145
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
146 146
     }
147 147
     /**
148 148
      * The Ajax Problem Solution Discussion Vote.
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
         $problemModel=new ProblemModel();
158 158
         $psoid=$all_data["psoid"];
159 159
         $type=$all_data["type"];
160
-        $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type);
161
-        return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004);
160
+        $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type);
161
+        return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004);
162 162
     }
163 163
     /**
164 164
      * The Ajax Problem Solution Submit.
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 
252 252
         $submissionData=$submissionModel->basic($all_data["sid"]);
253 253
 
254
-        if($submissionData["uid"]!=Auth::user()->id){
254
+        if ($submissionData["uid"]!=Auth::user()->id) {
255 255
             return ResponseModel::err(2001);
256 256
         }
257 257
 
258
-        if($submissionData["verdict"]!="Submission Error"){
258
+        if ($submissionData["verdict"]!="Submission Error") {
259 259
             return ResponseModel::err(6003);
260 260
         }
261 261
 
262
-        $submissionModel->updateSubmission($all_data["sid"],[
262
+        $submissionModel->updateSubmission($all_data["sid"], [
263 263
             "verdict"=>"Pending",
264 264
             "time"=>0,
265 265
             "memory"=>0
Please login to merge, or discard this patch.
app/Models/ProblemModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,9 +177,9 @@
 block discarded – undo
177 177
 
178 178
     private function inteliAudit($uid, $content)
179 179
     {
180
-        if (strpos($content, '```')!==false){
180
+        if (strpos($content, '```')!==false) {
181 181
             $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first();
182
-            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){
182
+            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) {
183 183
                 return 1;
184 184
             }
185 185
         }
Please login to merge, or discard this patch.
app/Models/Search/GroupSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 
13 13
     public function search($key)
14 14
     {
15
-        $result = [];
15
+        $result=[];
16 16
         //group name or gcode find
17
-        if(strlen($key) >= 2){
18
-            $ret = self::where(function($query) use ($key){
19
-                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
17
+        if (strlen($key)>=2) {
18
+            $ret=self::where(function($query) use ($key){
19
+                $query->whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
20 20
                     ->orWhere('gcode', $key);
21 21
                 })
22
-                ->where('public',1)
23
-                ->select('gid','gcode', 'img', 'name', 'description')
22
+                ->where('public', 1)
23
+                ->select('gid', 'gcode', 'img', 'name', 'description')
24 24
                 ->limit(120)
25 25
                 ->get()->all();
26
-            if(!empty($ret)){
27
-                $result += $ret;
26
+            if (!empty($ret)) {
27
+                $result+=$ret;
28 28
             }
29 29
         }
30 30
 
Please login to merge, or discard this patch.
app/Models/Search/ProblemSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 
14 14
     public function search($key)
15 15
     {
16
-        $result = [];
17
-        if(strlen($key) >= 2){
18
-            $ret = self::where('pcode', $key)
19
-                ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)',[$key])
16
+        $result=[];
17
+        if (strlen($key)>=2) {
18
+            $ret=self::where('pcode', $key)
19
+                ->orWhereRaw('MATCH(`title`) AGAINST (? IN BOOLEAN MODE)', [$key])
20 20
                 ->select('pcode', 'title')
21 21
                 ->limit(120)
22 22
                 ->get()->all();
23
-            if(!empty($ret)){
24
-                $result += $ret;
23
+            if (!empty($ret)) {
24
+                $result+=$ret;
25 25
             }
26 26
         }
27
-        $problemModel = new ProblemModel();
27
+        $problemModel=new ProblemModel();
28 28
         foreach ($result as $p_index => $p) {
29
-            if($problemModel->isBlocked($p['pid'])){
29
+            if ($problemModel->isBlocked($p['pid'])) {
30 30
                 unset($result[$p_index]);
31 31
             }
32 32
         }
Please login to merge, or discard this patch.
app/Models/Search/ContestSearchModel.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
 
16 16
     public function search($key)
17 17
     {
18
-        $result = [];
18
+        $result=[];
19 19
         //contest name find
20
-        if(strlen($key) >= 2){
21
-            $ret = self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
20
+        if (strlen($key)>=2) {
21
+            $ret=self::whereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
22 22
                 ->select('cid', 'gid', 'name', 'rule', 'public', 'verified', 'practice', 'rated', 'anticheated', 'begin_time', 'end_time')
23
-                ->orderBy('end_time','DESC')
23
+                ->orderBy('end_time', 'DESC')
24 24
                 ->limit(120)
25 25
                 ->get()->all();
26
-            $user_id = Auth::user()->id;
27
-            $contestModel = new ContestModel();
28
-            foreach($ret as $c_index => $c){
29
-                if(!$contestModel->judgeClearance($c['cid'],$user_id)){
26
+            $user_id=Auth::user()->id;
27
+            $contestModel=new ContestModel();
28
+            foreach ($ret as $c_index => $c) {
29
+                if (!$contestModel->judgeClearance($c['cid'], $user_id)) {
30 30
                     unset($ret[$c_index]);
31 31
                 }
32 32
             }
33
-            if(!empty($ret)){
34
-                $result += $ret;
33
+            if (!empty($ret)) {
34
+                $result+=$ret;
35 35
             }
36 36
         }
37
-        if(!empty($result)) {
37
+        if (!empty($result)) {
38 38
             foreach ($result as &$contest) {
39 39
                 $contest["rule_parsed"]=$this->rule[$contest["rule"]];
40 40
                 $contest["date_parsed"]=[
Please login to merge, or discard this patch.
app/Models/Search/UserSearchModel.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
 
11 11
     public function search($key)
12 12
     {
13
-        $result = [];
14
-        if(strlen($key) >= 2){
15
-            $ret = self::where('email',$key)
16
-                ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)',[$key])
17
-                ->select('id','avatar', 'name',  'describes', 'professional_rate')
18
-                ->orderBy('professional_rate','DESC')
13
+        $result=[];
14
+        if (strlen($key)>=2) {
15
+            $ret=self::where('email', $key)
16
+                ->orWhereRaw('MATCH(`name`) AGAINST (? IN BOOLEAN MODE)', [$key])
17
+                ->select('id', 'avatar', 'name', 'describes', 'professional_rate')
18
+                ->orderBy('professional_rate', 'DESC')
19 19
                 ->limit(120)
20 20
                 ->get()->all();
21
-            if(!empty($ret)){
22
-                $result += $ret;
21
+            if (!empty($ret)) {
22
+                $result+=$ret;
23 23
             }
24 24
         }
25 25
         return $result;
Please login to merge, or discard this patch.