Passed
Push — master ( 3dac84...29c427 )
by John
13:35 queued 04:51
created
app/Babel/Judge/Judger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
         $result=$submissionModel->getWaitingSubmission();
31 31
 
32
-        $submissionCount = count($result);
32
+        $submissionCount=count($result);
33 33
 
34 34
         Log::channel('babel_judge_sync')->info("Currently $submissionCount submission(s) awaiting", [$result]);
35 35
 
Please login to merge, or discard this patch.
app/Models/Eloquent/User.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
         return $socialites;
181 181
     }
182 182
 
183
-    public function problems_latest_submission($problems, $contestID = null, Carbon $till = null, $verdictFilter = [])
183
+    public function problems_latest_submission($problems, $contestID=null, Carbon $till=null, $verdictFilter=[])
184 184
     {
185 185
         if (filled($contestID)) {
186
-            $endedAt = Carbon::parse(Contest::findOrFail($contestID)->endedAt);
186
+            $endedAt=Carbon::parse(Contest::findOrFail($contestID)->endedAt);
187 187
         }
188 188
 
189
-        $lastRecordSubQuery = $this->submissions()->select('pid', DB::raw('MAX(submission_date) as submission_date'))->whereIntegerInRaw('pid', $problems)->where('cid', $contestID)->groupBy('pid');
189
+        $lastRecordSubQuery=$this->submissions()->select('pid', DB::raw('MAX(submission_date) as submission_date'))->whereIntegerInRaw('pid', $problems)->where('cid', $contestID)->groupBy('pid');
190 190
 
191 191
         if (filled($contestID)) {
192
-            $lastRecordSubQuery = $lastRecordSubQuery->where("submission_date", "<", $endedAt->timestamp);
192
+            $lastRecordSubQuery=$lastRecordSubQuery->where("submission_date", "<", $endedAt->timestamp);
193 193
         }
194 194
 
195 195
         if (filled($till)) {
196
-            $lastRecordSubQuery = $lastRecordSubQuery->where("submission_date", "<", $till->timestamp);
196
+            $lastRecordSubQuery=$lastRecordSubQuery->where("submission_date", "<", $till->timestamp);
197 197
         }
198 198
 
199
-        if(filled($verdictFilter)) {
200
-            $lastRecordSubQuery = $lastRecordSubQuery->whereIn('verdict', $verdictFilter);
199
+        if (filled($verdictFilter)) {
200
+            $lastRecordSubQuery=$lastRecordSubQuery->whereIn('verdict', $verdictFilter);
201 201
         }
202 202
 
203
-        $query = DB::table(DB::raw("({$lastRecordSubQuery->toSql()}) last_sub"))->leftJoinSub(Submission::toBase(), 'submissions', function ($join) {
203
+        $query=DB::table(DB::raw("({$lastRecordSubQuery->toSql()}) last_sub"))->leftJoinSub(Submission::toBase(), 'submissions', function($join) {
204 204
             $join->on('last_sub.submission_date', '=', 'submissions.submission_date')->on('last_sub.pid', '=', 'submissions.pid');
205 205
         })->select('sid', 'last_sub.submission_date as submission_date', 'last_sub.pid as pid', 'verdict', 'color')->orderBy('pid', 'ASC');
206 206
 
@@ -210,40 +210,40 @@  discard block
 block discarded – undo
210 210
     public function getDojoStatistics()
211 211
     {
212 212
         try {
213
-            $statistics = [];
214
-            $problemIDArr = DojoProblem::select('problem_id')->distinct()->get()->pluck('problem_id');
213
+            $statistics=[];
214
+            $problemIDArr=DojoProblem::select('problem_id')->distinct()->get()->pluck('problem_id');
215 215
 
216 216
             foreach ($problemIDArr as $problemID) {
217
-                $statistics[$problemID] = [
217
+                $statistics[$problemID]=[
218 218
                     "icon" => "checkbox-blank-circle-outline",
219 219
                     "color" => "wemd-grey-text"
220 220
                 ];
221 221
             }
222 222
 
223
-            $problemCompleteIDArr = [];
223
+            $problemCompleteIDArr=[];
224 224
 
225 225
             foreach ($this->problems_latest_submission($problemIDArr->diff($problemCompleteIDArr), null, null, ['Accepted'])->get() as $acceptedRecord) {
226
-                $statistics[$acceptedRecord['pid']] = [
226
+                $statistics[$acceptedRecord['pid']]=[
227 227
                     "icon" => "checkbox-blank-circle",
228 228
                     "color" => $acceptedRecord['color']
229 229
                 ];
230
-                $problemCompleteIDArr[] = $acceptedRecord['pid'];
230
+                $problemCompleteIDArr[]=$acceptedRecord['pid'];
231 231
             }
232 232
 
233 233
             foreach ($this->problems_latest_submission($problemIDArr->diff($problemCompleteIDArr), null, null, ['Partially Accepted'])->get() as $acceptedRecord) {
234
-                $statistics[$acceptedRecord['pid']] = [
234
+                $statistics[$acceptedRecord['pid']]=[
235 235
                     "icon" => "cisco-webex",
236 236
                     "color" => $acceptedRecord['color']
237 237
                 ];
238
-                $problemCompleteIDArr[] = $acceptedRecord['pid'];
238
+                $problemCompleteIDArr[]=$acceptedRecord['pid'];
239 239
             }
240 240
 
241 241
             foreach ($this->problems_latest_submission($problemIDArr->diff($problemCompleteIDArr), null, null)->get() as $acceptedRecord) {
242
-                $statistics[$acceptedRecord['pid']] = [
242
+                $statistics[$acceptedRecord['pid']]=[
243 243
                     "icon" => "cisco-webex",
244 244
                     "color" => $acceptedRecord['color']
245 245
                 ];
246
-                $problemCompleteIDArr[] = $acceptedRecord['pid'];
246
+                $problemCompleteIDArr[]=$acceptedRecord['pid'];
247 247
             }
248 248
 
249 249
             return $statistics;
Please login to merge, or discard this patch.
app/Admin/Controllers/ApiController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@  discard block
 block discarded – undo
10 10
 
11 11
 class ApiController extends AdminController
12 12
 {
13
-    protected function paginate($items, $perPage = 15)
13
+    protected function paginate($items, $perPage=15)
14 14
     {
15
-        $currentPage = Paginator::resolveCurrentPage();
16
-        $offSet = ($currentPage * $perPage) - $perPage;
17
-        $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
18
-        $paginator = new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, $currentPage, ['path' => Paginator::resolveCurrentPath()]);
15
+        $currentPage=Paginator::resolveCurrentPage();
16
+        $offSet=($currentPage * $perPage)-$perPage;
17
+        $itemsForCurrentPage=array_slice($items, $offSet, $perPage, true);
18
+        $paginator=new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, $currentPage, ['path' => Paginator::resolveCurrentPath()]);
19 19
         return $paginator;
20 20
     }
21 21
 
22 22
     public function problems()
23 23
     {
24
-        $q = request()->q;
24
+        $q=request()->q;
25 25
 
26
-        return $this->paginate(Problem::like('pcode', $q)->orLike('title', $q)->orderBy('pcode', 'asc')->get()->values()->transform(function ($problem) {
26
+        return $this->paginate(Problem::like('pcode', $q)->orLike('title', $q)->orderBy('pcode', 'asc')->get()->values()->transform(function($problem) {
27 27
             return [
28 28
                 'id' => $problem->pid,
29 29
                 'text' => $problem->readable_name,
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function users()
35 35
     {
36
-        $q = request()->q;
36
+        $q=request()->q;
37 37
 
38
-        return $this->paginate(User::like('name', $q)->orLike('email', $q)->orderBy('id', 'asc')->get()->values()->transform(function ($user) {
38
+        return $this->paginate(User::like('name', $q)->orLike('email', $q)->orderBy('id', 'asc')->get()->values()->transform(function($user) {
39 39
             return [
40 40
                 'id' => $user->id,
41 41
                 'text' => $user->readable_name,
Please login to merge, or discard this patch.
app/Console/Commands/Scheduling/UpdateTrendingGroups.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
         $time=Carbon::now();
43 43
         $this->line("<fg=yellow>[$time] Processing:  </>Update Trending Groups");
44 44
 
45
-        $groupModel = new GroupModel();
45
+        $groupModel=new GroupModel();
46 46
         $groupModel->cacheTrendingGroups();
47 47
 
48 48
         $time=Carbon::now();
Please login to merge, or discard this patch.
app/Models/Eloquent/Problem.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 {
16 16
     use LikeScope;
17 17
 
18
-    protected $table = 'problem';
19
-    protected $primaryKey = 'pid';
20
-    const UPDATED_AT = "update_date";
18
+    protected $table='problem';
19
+    protected $primaryKey='pid';
20
+    const UPDATED_AT="update_date";
21 21
 
22 22
     protected function serializeDate(DateTimeInterface $date)
23 23
     {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function getReadableNameAttribute()
28 28
     {
29
-        return $this->pcode . '. ' . $this->title;
29
+        return $this->pcode.'. '.$this->title;
30 30
     }
31 31
 
32 32
     public function submissions()
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
         return $this->getProblemStatus();
55 55
     }
56 56
 
57
-    public function getProblemStatus($userID = null, $contestID = null, Carbon $till = null)
57
+    public function getProblemStatus($userID=null, $contestID=null, Carbon $till=null)
58 58
     {
59 59
         if (blank($userID)) {
60 60
             if (Auth::guard('web')->check()) {
61
-                $userID = Auth::guard('web')->user()->id;
61
+                $userID=Auth::guard('web')->user()->id;
62 62
             }
63 63
         }
64 64
 
65 65
         if (filled($userID)) {
66
-            $probStatus = $this->getProblemStatusFromDB($userID, $contestID, $till);
66
+            $probStatus=$this->getProblemStatusFromDB($userID, $contestID, $till);
67 67
             if (blank($probStatus)) {
68 68
                 return [
69 69
                     "icon" => "checkbox-blank-circle-outline",
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                 ];
72 72
             } else {
73 73
                 return [
74
-                    "icon" => $probStatus->verdict == "Accepted" ? "checkbox-blank-circle" : "cisco-webex",
74
+                    "icon" => $probStatus->verdict=="Accepted" ? "checkbox-blank-circle" : "cisco-webex",
75 75
                     "color" => $probStatus->color
76 76
                 ];
77 77
             }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
         }
84 84
     }
85 85
 
86
-    private function getProblemStatusFromDB($userID, $contestID = null, Carbon $till = null)
86
+    private function getProblemStatusFromDB($userID, $contestID=null, Carbon $till=null)
87 87
     {
88
-        $endedAt = Carbon::now();
88
+        $endedAt=Carbon::now();
89 89
 
90 90
         if (filled($contestID)) {
91 91
             try {
92
-                $endedAt = Carbon::parse(Contest::findOrFail($contestID)->endedAt);
92
+                $endedAt=Carbon::parse(Contest::findOrFail($contestID)->endedAt);
93 93
             } catch (Exception $e) {
94 94
                 return null;
95 95
             }
@@ -97,41 +97,41 @@  discard block
 block discarded – undo
97 97
 
98 98
         // Get the very first AC record
99 99
 
100
-        $acRecords = $this->submissions()->where([
100
+        $acRecords=$this->submissions()->where([
101 101
             'uid' => $userID,
102 102
             'cid' => $contestID,
103 103
             'verdict' => 'Accepted'
104 104
         ]);
105 105
         if (filled($contestID)) {
106
-            $acRecords = $acRecords->where("submission_date", "<", $endedAt->timestamp);
106
+            $acRecords=$acRecords->where("submission_date", "<", $endedAt->timestamp);
107 107
         }
108 108
         if (filled($till)) {
109
-            $acRecords = $acRecords->where("submission_date", "<", $till->timestamp);
109
+            $acRecords=$acRecords->where("submission_date", "<", $till->timestamp);
110 110
         }
111
-        $acRecords = $acRecords->orderBy('submission_date', 'desc')->first();
111
+        $acRecords=$acRecords->orderBy('submission_date', 'desc')->first();
112 112
         if (blank($acRecords)) {
113
-            $pacRecords = $this->submissions()->where([
113
+            $pacRecords=$this->submissions()->where([
114 114
                 'uid' => $userID,
115 115
                 'cid' => $contestID,
116 116
                 'verdict' => 'Partially Accepted'
117 117
             ]);
118 118
             if (filled($contestID)) {
119
-                $pacRecords = $pacRecords->where("submission_date", "<", $endedAt->timestamp);
119
+                $pacRecords=$pacRecords->where("submission_date", "<", $endedAt->timestamp);
120 120
             }
121 121
             if (filled($till)) {
122
-                $pacRecords = $pacRecords->where("submission_date", "<", $till->timestamp);
122
+                $pacRecords=$pacRecords->where("submission_date", "<", $till->timestamp);
123 123
             }
124
-            $pacRecords = $pacRecords->orderBy('submission_date', 'desc')->first();
124
+            $pacRecords=$pacRecords->orderBy('submission_date', 'desc')->first();
125 125
             if (blank($pacRecords)) {
126
-                $otherRecords = $this->submissions()->where([
126
+                $otherRecords=$this->submissions()->where([
127 127
                     'uid' => $userID,
128 128
                     'cid' => $contestID
129 129
                 ]);
130 130
                 if (filled($contestID)) {
131
-                    $otherRecords = $otherRecords->where("submission_date", "<", $endedAt->timestamp);
131
+                    $otherRecords=$otherRecords->where("submission_date", "<", $endedAt->timestamp);
132 132
                 }
133 133
                 if (filled($till)) {
134
-                    $otherRecords = $otherRecords->where("submission_date", "<", $till->timestamp);
134
+                    $otherRecords=$otherRecords->where("submission_date", "<", $till->timestamp);
135 135
                 }
136 136
                 return $otherRecords->orderBy('submission_date', 'desc')->first();
137 137
             }
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
         }
142 142
     }
143 143
 
144
-    public function users_latest_submission($users, $contestID = null, Carbon $till = null, $verdictFilter = [])
144
+    public function users_latest_submission($users, $contestID=null, Carbon $till=null, $verdictFilter=[])
145 145
     {
146 146
         if (filled($contestID)) {
147
-            $endedAt = Carbon::parse(Contest::findOrFail($contestID)->endedAt);
147
+            $endedAt=Carbon::parse(Contest::findOrFail($contestID)->endedAt);
148 148
         }
149 149
 
150
-        $lastRecordSubQuery = $this->submissions()->select('uid', DB::raw('MAX(submission_date) as submission_date'))->whereIntegerInRaw('uid', $users)->where('cid', $contestID)->groupBy('uid');
150
+        $lastRecordSubQuery=$this->submissions()->select('uid', DB::raw('MAX(submission_date) as submission_date'))->whereIntegerInRaw('uid', $users)->where('cid', $contestID)->groupBy('uid');
151 151
 
152 152
         if (filled($contestID)) {
153
-            $lastRecordSubQuery = $lastRecordSubQuery->where("submission_date", "<", $endedAt->timestamp);
153
+            $lastRecordSubQuery=$lastRecordSubQuery->where("submission_date", "<", $endedAt->timestamp);
154 154
         }
155 155
 
156 156
         if (filled($till)) {
157
-            $lastRecordSubQuery = $lastRecordSubQuery->where("submission_date", "<", $till->timestamp);
157
+            $lastRecordSubQuery=$lastRecordSubQuery->where("submission_date", "<", $till->timestamp);
158 158
         }
159 159
 
160
-        if(filled($verdictFilter)) {
161
-            $lastRecordSubQuery = $lastRecordSubQuery->whereIn('verdict', $verdictFilter);
160
+        if (filled($verdictFilter)) {
161
+            $lastRecordSubQuery=$lastRecordSubQuery->whereIn('verdict', $verdictFilter);
162 162
         }
163 163
 
164
-        $query = DB::table(DB::raw("({$lastRecordSubQuery->toSql()}) last_sub"))->leftJoinSub(Submission::toBase(), 'submissions', function ($join) {
164
+        $query=DB::table(DB::raw("({$lastRecordSubQuery->toSql()}) last_sub"))->leftJoinSub(Submission::toBase(), 'submissions', function($join) {
165 165
             $join->on('last_sub.submission_date', '=', 'submissions.submission_date')->on('last_sub.uid', '=', 'submissions.uid');
166 166
         })->select('sid', 'last_sub.submission_date as submission_date', 'last_sub.uid as uid', 'verdict', 'color')->orderBy('uid', 'ASC');
167 167
 
Please login to merge, or discard this patch.
app/Models/Eloquent/Tool/SiteRank.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 class SiteRank
14 14
 {
15
-    private static $professionalRanking = [
15
+    private static $professionalRanking=[
16 16
         "Legendary Grandmaster" => "cm-colorful-text",
17 17
         "International Grandmaster" => "wemd-pink-text",
18 18
         "Grandmaster" => "wemd-red-text",
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         "Newbie" => "wemd-gray-text",
26 26
     ];
27 27
 
28
-    private static $professionalRankingPer = [
28
+    private static $professionalRankingPer=[
29 29
         "Legendary Grandmaster" => 3000,
30 30
         "International Grandmaster" => 2600,
31 31
         "Grandmaster" => 2400,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         "Newbie" => 1,
39 39
     ];
40 40
 
41
-    private static $casualRanking = [
41
+    private static $casualRanking=[
42 42
         "Fleet Admiral" => "cm-colorful-text",
43 43
         "Admiral" => "wemd-pink-text",
44 44
         "Vice Admiral" => "wemd-red-text",
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         "Recruit" => "wemd-gray-text",
52 52
     ];
53 53
 
54
-    private static $casualRankingPer = [
54
+    private static $casualRankingPer=[
55 55
         "Fleet Admiral" => 1,
56 56
         "Admiral" => 5,
57 57
         "Vice Admiral" => 10,
@@ -82,49 +82,49 @@  discard block
 block discarded – undo
82 82
 
83 83
     public static function list($num)
84 84
     {
85
-        $rankList = Cache::tags(['rank'])->get('general');
86
-        if ($rankList == null) {
87
-            $rankList = [];
88
-        }
89
-        $rankList = collect($rankList)->slice(0, $num);
90
-        $userIDArr = $rankList->pluck('uid');
91
-        $userInfoRaw = User::whereIntegerInRaw('id', $userIDArr)->get();
92
-        $userInfo = [];
85
+        $rankList=Cache::tags(['rank'])->get('general');
86
+        if ($rankList==null) {
87
+            $rankList=[];
88
+        }
89
+        $rankList=collect($rankList)->slice(0, $num);
90
+        $userIDArr=$rankList->pluck('uid');
91
+        $userInfoRaw=User::whereIntegerInRaw('id', $userIDArr)->get();
92
+        $userInfo=[];
93 93
         foreach ($userInfoRaw as $u) {
94
-            $userInfo[$u->id] = $u;
94
+            $userInfo[$u->id]=$u;
95 95
         }
96
-        return $rankList->map(function ($item) use ($userInfo) {
97
-            $item["details"] = isset($userInfo[$item["uid"]]) ? $userInfo[$item["uid"]] : [];
96
+        return $rankList->map(function($item) use ($userInfo) {
97
+            $item["details"]=isset($userInfo[$item["uid"]]) ? $userInfo[$item["uid"]] : [];
98 98
             return $item;
99 99
         });
100 100
     }
101 101
 
102
-    private static function getRecords(Carbon $from = null)
102
+    private static function getRecords(Carbon $from=null)
103 103
     {
104
-        $userAcceptedRecords = Submission::select("uid", DB::raw("count(distinct pid) as solved"))->where("verdict", "Accepted");
105
-        $userCommunityRecords = ProblemSolution::select("uid", DB::raw("count(distinct pid) as community"))->where("audit", 1);
106
-        if(filled($from)){
107
-            $userAcceptedRecords = $userAcceptedRecords->where("submission_date", ">", $from->timestamp);
108
-            $userCommunityRecords = $userCommunityRecords->where("created_at", ">", $from);
109
-        }
110
-        $userAcceptedRecords = collect($userAcceptedRecords->groupBy("uid")->get()->toArray());
111
-        $userCommunityRecords = collect($userCommunityRecords->groupBy("uid")->get()->toArray());
112
-        $totUserRecords = $userAcceptedRecords->pluck('uid')->merge($userCommunityRecords->pluck('uid'))->unique();
113
-        $rankList = [];
114
-        foreach($totUserRecords as $uid) {
115
-            $rankList[$uid]['uid'] = $uid;
116
-            $rankList[$uid]['solved'] = 0;
117
-            $rankList[$uid]['community'] = 0;
118
-            $rankList[$uid]['tot'] = 0;
119
-        }
120
-        foreach($userAcceptedRecords as $userAcceptedRecord) {
121
-            $rankList[$userAcceptedRecord['uid']]['solved'] = $userAcceptedRecord['solved'];
122
-        }
123
-        foreach($userCommunityRecords as $userCommunityRecord) {
124
-            $rankList[$userCommunityRecord['uid']]['community'] = $userCommunityRecord['community'];
125
-        }
126
-        foreach($rankList as &$rankItem) {
127
-            $rankItem['tot'] = $rankItem['solved'] + $rankItem['community'];
104
+        $userAcceptedRecords=Submission::select("uid", DB::raw("count(distinct pid) as solved"))->where("verdict", "Accepted");
105
+        $userCommunityRecords=ProblemSolution::select("uid", DB::raw("count(distinct pid) as community"))->where("audit", 1);
106
+        if (filled($from)) {
107
+            $userAcceptedRecords=$userAcceptedRecords->where("submission_date", ">", $from->timestamp);
108
+            $userCommunityRecords=$userCommunityRecords->where("created_at", ">", $from);
109
+        }
110
+        $userAcceptedRecords=collect($userAcceptedRecords->groupBy("uid")->get()->toArray());
111
+        $userCommunityRecords=collect($userCommunityRecords->groupBy("uid")->get()->toArray());
112
+        $totUserRecords=$userAcceptedRecords->pluck('uid')->merge($userCommunityRecords->pluck('uid'))->unique();
113
+        $rankList=[];
114
+        foreach ($totUserRecords as $uid) {
115
+            $rankList[$uid]['uid']=$uid;
116
+            $rankList[$uid]['solved']=0;
117
+            $rankList[$uid]['community']=0;
118
+            $rankList[$uid]['tot']=0;
119
+        }
120
+        foreach ($userAcceptedRecords as $userAcceptedRecord) {
121
+            $rankList[$userAcceptedRecord['uid']]['solved']=$userAcceptedRecord['solved'];
122
+        }
123
+        foreach ($userCommunityRecords as $userCommunityRecord) {
124
+            $rankList[$userCommunityRecord['uid']]['community']=$userCommunityRecord['community'];
125
+        }
126
+        foreach ($rankList as &$rankItem) {
127
+            $rankItem['tot']=$rankItem['solved']+$rankItem['community'];
128 128
         }
129 129
         unset($rankItem);
130 130
         return $rankList;
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
 
133 133
     private static function parseCoefficient($rankList)
134 134
     {
135
-        $activityCoefficient = self::getRecords(Carbon::parse('-1 months'));
136
-        $activityCoefficientDivider = collect($activityCoefficient)->max('tot');
137
-        if(blank($activityCoefficientDivider)) {
138
-            $activityCoefficientDivider = 1;
135
+        $activityCoefficient=self::getRecords(Carbon::parse('-1 months'));
136
+        $activityCoefficientDivider=collect($activityCoefficient)->max('tot');
137
+        if (blank($activityCoefficientDivider)) {
138
+            $activityCoefficientDivider=1;
139 139
         }
140 140
         foreach ($rankList as $uid => $rankItem) {
141
-            if(isset($activityCoefficient[$uid])){
142
-                $activityTot = $activityCoefficient[$uid]['tot'];
141
+            if (isset($activityCoefficient[$uid])) {
142
+                $activityTot=$activityCoefficient[$uid]['tot'];
143 143
             } else {
144
-                $activityTot = 0;
144
+                $activityTot=0;
145 145
             }
146
-            $rankList[$uid]["activityCoefficient"] = ($activityTot / $activityCoefficientDivider) + 0.5;
147
-            $rankList[$uid]["points"] = $rankList[$uid]["tot"] * $rankList[$uid]["activityCoefficient"];
146
+            $rankList[$uid]["activityCoefficient"]=($activityTot / $activityCoefficientDivider)+0.5;
147
+            $rankList[$uid]["points"]=$rankList[$uid]["tot"] * $rankList[$uid]["activityCoefficient"];
148 148
         }
149 149
         usort($rankList, function($a, $b) {
150 150
             return $b['points'] <=> $a['points'];
@@ -155,25 +155,25 @@  discard block
 block discarded – undo
155 155
     public static function rankList()
156 156
     {
157 157
         Cache::tags(['rank'])->flush();
158
-        $rankList = self::getRecords();
159
-        $totUsers = count($rankList);
160
-        if ($totUsers > 0) {
158
+        $rankList=self::getRecords();
159
+        $totUsers=count($rankList);
160
+        if ($totUsers>0) {
161 161
             // $rankList = DB::select("SELECT *,solvedCount+communityCount as totValue, 1 as activityCoefficient FROM (SELECT uid,sum(solvedCount) as solvedCount,sum(communityCount) as communityCount FROM ((SELECT uid,count(DISTINCT submission.pid) as solvedCount,0 as communityCount from submission where verdict=\"Accepted\" group by uid) UNION (SELECT uid,0 as solvedCount,count(DISTINCT pid) from problem_solution where audit=1 group by uid)) as temp GROUP BY uid) as temp2 ORDER BY solvedCount+communityCount DESC");
162
-            $rankList = self::parseCoefficient($rankList);
163
-            $rankIter = 1;
164
-            $rankValue = 1;
165
-            $rankSolved = -1;
166
-            $rankListCached = [];
162
+            $rankList=self::parseCoefficient($rankList);
163
+            $rankIter=1;
164
+            $rankValue=1;
165
+            $rankSolved=-1;
166
+            $rankListCached=[];
167 167
             self::procRankingPer($totUsers);
168 168
             foreach ($rankList as $rankItem) {
169
-                if ($rankSolved != $rankItem["points"]) {
170
-                    $rankValue = $rankIter;
171
-                    $rankSolved = $rankItem["points"];
169
+                if ($rankSolved!=$rankItem["points"]) {
170
+                    $rankValue=$rankIter;
171
+                    $rankSolved=$rankItem["points"];
172 172
                 }
173
-                $rankTitle = self::getRankTitle($rankValue);
173
+                $rankTitle=self::getRankTitle($rankValue);
174 174
                 Cache::tags(['rank', $rankItem["uid"]])->put("rank", $rankValue, 86400);
175 175
                 Cache::tags(['rank', $rankItem["uid"]])->put("title", $rankTitle, 86400);
176
-                $rankListCached[] = [
176
+                $rankListCached[]=[
177 177
                     "uid" => $rankItem["uid"],
178 178
                     "rank" => $rankValue,
179 179
                     "title" => $rankTitle,
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 
191 191
     public static function getProfessionalRanking()
192 192
     {
193
-        $professionalRankList = [];
194
-        $verifiedUsers = User::all();
195
-        $rankIter = 0;
193
+        $professionalRankList=[];
194
+        $verifiedUsers=User::all();
195
+        $rankIter=0;
196 196
         foreach ($verifiedUsers as $user) {
197
-            $rankVal = $user->professional_rate;
198
-            $rankTitle = self::getProfessionalTitle($rankVal);
199
-            $titleColor = self::getProfessionalColor($rankTitle);
200
-            $professionalRankList[$rankIter++] = [
197
+            $rankVal=$user->professional_rate;
198
+            $rankTitle=self::getProfessionalTitle($rankVal);
199
+            $titleColor=self::getProfessionalColor($rankTitle);
200
+            $professionalRankList[$rankIter++]=[
201 201
                 "name" => $user->name,
202 202
                 "uid" => $user->id,
203 203
                 "avatar" => $user->avatar,
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 
212 212
     private static function procRankingPer($totUsers)
213 213
     {
214
-        if ($totUsers > 0) {
215
-            $tot = 0;
216
-            $cur = 0;
214
+        if ($totUsers>0) {
215
+            $tot=0;
216
+            $cur=0;
217 217
             foreach (self::$casualRankingPer as $c) {
218
-                $tot += $c;
218
+                $tot+=$c;
219 219
             }
220 220
             foreach (self::$casualRankingPer as &$c) {
221
-                $c = round($c * $totUsers / $tot);
222
-                $cur += $c;
223
-                $c = $cur;
221
+                $c=round($c * $totUsers / $tot);
222
+                $cur+=$c;
223
+                $c=$cur;
224 224
             }
225
-            $c = $totUsers;
225
+            $c=$totUsers;
226 226
             unset($c);
227 227
         }
228 228
     }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     public static function getRankTitle($rankVal)
231 231
     {
232 232
         foreach (self::$casualRankingPer as $title => $c) {
233
-            if ($rankVal <= $c) {
233
+            if ($rankVal<=$c) {
234 234
                 return $title;
235 235
             }
236 236
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public static function getProfessionalTitle($rankVal)
241 241
     {
242 242
         foreach (self::$professionalRankingPer as $title => $point) {
243
-            if ($rankVal >= $point) {
243
+            if ($rankVal>=$point) {
244 244
                 return $title;
245 245
             }
246 246
         }
Please login to merge, or discard this patch.
app/Jobs/AntiCheat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
         // wildcardly add all files
138 138
         $exec.='*.'.$lang;
139 139
 
140
-        $process = Process::fromShellCommandline($exec);
140
+        $process=Process::fromShellCommandline($exec);
141 141
         $process->setWorkingDirectory(Storage::path('contest'.DIRECTORY_SEPARATOR.'anticheat'.DIRECTORY_SEPARATOR.$cid.DIRECTORY_SEPARATOR.'raw'.DIRECTORY_SEPARATOR.$prob.DIRECTORY_SEPARATOR.$lang));
142 142
         $process->run();
143 143
         if (!$process->isSuccessful()) {
Please login to merge, or discard this patch.
app/Jobs/GeneratePDF.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 {
21 21
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable;
22 22
 
23
-    public $tries = 1;
23
+    public $tries=1;
24 24
     protected $cid;
25 25
     protected $config;
26 26
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
     public function __construct($cid, $config)
34 34
     {
35 35
         $this->prepareStatus();
36
-        $this->cid = $cid;
37
-        $default = [
36
+        $this->cid=$cid;
37
+        $default=[
38 38
             'cover' => false,
39 39
             'advice' => false,
40 40
         ];
41
-        $this->config = array_merge($default, $config);
41
+        $this->config=array_merge($default, $config);
42 42
     }
43 43
 
44 44
     /**
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function handle()
50 50
     {
51
-        $cid = $this->cid;
52
-        $config = $this->config;
53
-        $accessToken = Str::random(32);
51
+        $cid=$this->cid;
52
+        $config=$this->config;
53
+        $accessToken=Str::random(32);
54 54
 
55 55
         Cache::tags(['contest', 'pdfViewAccess', $cid])->put($accessToken, $config);
56 56
 
@@ -58,23 +58,23 @@  discard block
 block discarded – undo
58 58
             mkdir(storage_path("app/contest/pdf/"), 0777, true);
59 59
         }
60 60
 
61
-        $record = Contest::find($cid);
61
+        $record=Contest::find($cid);
62 62
 
63
-        $puppeteer = new Puppeteer;
64
-        $browser = $puppeteer->launch([
63
+        $puppeteer=new Puppeteer;
64
+        $browser=$puppeteer->launch([
65 65
             'args' => ['--no-sandbox', '--disable-setuid-sandbox'],
66 66
         ]);
67 67
 
68
-        $page = $browser->newPage();
68
+        $page=$browser->newPage();
69 69
 
70
-        $response = $page->goto(route('contest.board.admin.pdf.view', [
70
+        $response=$page->goto(route('contest.board.admin.pdf.view', [
71 71
             'cid' => $cid,
72 72
             'accessToken' => $accessToken,
73 73
         ]), [
74 74
             'waitUntil' => 'networkidle0'
75 75
         ]);
76 76
 
77
-        if($response->status() != '200') {
77
+        if ($response->status()!='200') {
78 78
             throw new Exception('Cannot Access PDF Generated View Stream');
79 79
         }
80 80
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'timeout' => 120000
83 83
         ]);
84 84
 
85
-        if($config['renderer'] == 'blink') {
85
+        if ($config['renderer']=='blink') {
86 86
             $page->pdf([
87 87
                 'format' => 'A4',
88 88
                 'path' => storage_path("app/contest/pdf/$cid.pdf"),
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             return;
94 94
         }
95 95
 
96
-        $parsedHTML = $page->content();
96
+        $parsedHTML=$page->content();
97 97
 
98 98
         $browser->close();
99 99
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             'BaseURL' => route('contest.detail', ['cid' => $cid]),
134 134
         ])->save(storage_path("app/contest/pdf/$cid.pdf"));
135 135
 
136
-        $record->pdf = 1;
136
+        $record->pdf=1;
137 137
         $record->save();
138 138
     }
139 139
 
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/ContestAdminController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
         $all_data=$request->all();
89 89
         $filter=$all_data['filter'];
90
-        $filter=Arr::where($filter, function ($value, $key) {
90
+        $filter=Arr::where($filter, function($value, $key) {
91 91
             return in_array($value, [
92 92
                 "Judge Error",
93 93
                 "System Error",
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
             "config.formula"=>"required|string",
343 343
         ]);
344 344
         $cid=$request->input('cid');
345
-        $renderer = $request->input('config.renderer');
346
-        $formula = $request->input('config.formula');
347
-        if($renderer == 'blink') {
348
-            if($formula != 'tex') {
345
+        $renderer=$request->input('config.renderer');
346
+        $formula=$request->input('config.formula');
347
+        if ($renderer=='blink') {
348
+            if ($formula!='tex') {
349 349
                 return ResponseModel::err(4011, 'Illegal Formula Rendering Option.');
350 350
             }
351
-        } else if ($renderer == 'cpdf') {
352
-            if($formula != 'svg' && $formula != 'png') {
351
+        } else if ($renderer=='cpdf') {
352
+            if ($formula!='svg' && $formula!='png') {
353 353
                 return ResponseModel::err(4011, 'Illegal Formula Rendering Option.');
354 354
             }
355 355
         } else {
Please login to merge, or discard this patch.