@@ -86,11 +86,11 @@ |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | public function process($students,$count,$type){ |
89 | - if($type === 'duplicate'){ |
|
89 | + if($type === 'duplicate'){ |
|
90 | 90 | array_walk($students,array($this,'cleanData')); |
91 | - }elseif($type === 'lock'){ |
|
91 | + }elseif($type === 'lock'){ |
|
92 | 92 | array_walk($students,array($this,'lockData')); |
93 | - } |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function lockData($Student){ |
@@ -48,72 +48,72 @@ discard block |
||
48 | 48 | { |
49 | 49 | $type = $this->argument('type'); |
50 | 50 | $students = array(); |
51 | - if($type == 'invalid'){ |
|
51 | + if ($type == 'invalid') { |
|
52 | 52 | $students = DB::table('examination_students as es') |
53 | 53 | ->whereRaw('CHAR_LENGTH(nsid) > 11') |
54 | 54 | ->get() |
55 | 55 | ->toArray(); |
56 | - }elseif($type == 'duplicate'){ |
|
56 | + }elseif ($type == 'duplicate') { |
|
57 | 57 | $students = DB::table('security_users') |
58 | 58 | ->where('updated_from', 'doe') |
59 | 59 | ->get() |
60 | 60 | ->toArray(); |
61 | 61 | |
62 | - }elseif($type == 'all'){ |
|
62 | + }elseif ($type == 'all') { |
|
63 | 63 | $students = DB::table('examination_students') |
64 | - ->where('nsid','<>','') |
|
64 | + ->where('nsid', '<>', '') |
|
65 | 65 | ->whereNotNull('nsid') |
66 | 66 | ->get() |
67 | 67 | ->toArray(); |
68 | - }elseif($type == 'lock'){ |
|
68 | + }elseif ($type == 'lock') { |
|
69 | 69 | $students = DB::table('examination_students') |
70 | - ->where('nsid','<>','') |
|
70 | + ->where('nsid', '<>', '') |
|
71 | 71 | ->whereNotNull('nsid') |
72 | 72 | ->get() |
73 | 73 | ->toArray(); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $this->output->writeln('###########################################------Start cleanning exam records------###########################################'); |
77 | - if(count($students) > 0){ |
|
78 | - $this->output->writeln('Total students to clean: '. count($students)); |
|
77 | + if (count($students) > 0) { |
|
78 | + $this->output->writeln('Total students to clean: '.count($students)); |
|
79 | 79 | $students = array_chunk($students, $this->argument('chunk')); |
80 | 80 | $function = array($this, 'process'); |
81 | - processParallel($function,$students, $this->argument('max'),$type); |
|
82 | - }else{ |
|
81 | + processParallel($function, $students, $this->argument('max'), $type); |
|
82 | + }else { |
|
83 | 83 | $this->output->writeln('nothing to process, all are cleaned'); |
84 | 84 | } |
85 | 85 | $this->output->writeln('###########################################------Finished cleaning exam records------###########################################'); |
86 | 86 | } |
87 | 87 | |
88 | - public function process($students,$count,$type){ |
|
89 | - if($type === 'duplicate'){ |
|
90 | - array_walk($students,array($this,'cleanData')); |
|
91 | - }elseif($type === 'lock'){ |
|
92 | - array_walk($students,array($this,'lockData')); |
|
88 | + public function process($students, $count, $type) { |
|
89 | + if ($type === 'duplicate') { |
|
90 | + array_walk($students, array($this, 'cleanData')); |
|
91 | + }elseif ($type === 'lock') { |
|
92 | + array_walk($students, array($this, 'lockData')); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - public function lockData($Student){ |
|
97 | - $Student = json_decode(json_encode($Student),true); |
|
98 | - $student = Security_user::where('openemis_no',(string)$Student['nsid'])->first(); |
|
99 | - if(!empty($student)){ |
|
96 | + public function lockData($Student) { |
|
97 | + $Student = json_decode(json_encode($Student), true); |
|
98 | + $student = Security_user::where('openemis_no', (string) $Student['nsid'])->first(); |
|
99 | + if (!empty($student)) { |
|
100 | 100 | Institution_student::where('student_id', $student->id)->update(['updated_from' => 'doe']); |
101 | 101 | Security_user::where('id', $student->id)->update(['updated_from' => 'doe']); |
102 | - $this->output->writeln('Locked:'. (string)$Student['nsid'] .':' . $student['openemis_no']); |
|
102 | + $this->output->writeln('Locked:'.(string) $Student['nsid'].':'.$student['openemis_no']); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | public function cleanData($Student) |
108 | 108 | { |
109 | - $exist = Examination_student::where('nsid','=', (string)$Student->openemis_no)->count(); |
|
109 | + $exist = Examination_student::where('nsid', '=', (string) $Student->openemis_no)->count(); |
|
110 | 110 | if (!$exist) { |
111 | 111 | Institution_student::where('student_id', $Student->id)->delete(); |
112 | 112 | Institution_class_student::where('student_id', $Student->id)->delete(); |
113 | 113 | Institution_student_admission::where('student_id', $Student->id)->delete(); |
114 | 114 | Security_user::where('id', $Student->id)->delete(); |
115 | - $this->output->writeln('cleaned:'. (string)$Student->openemis_no); |
|
116 | - }else{ |
|
115 | + $this->output->writeln('cleaned:'.(string) $Student->openemis_no); |
|
116 | + }else { |
|
117 | 117 | Institution_student::where('student_id', $Student->id)->update(['updated_from' => 'doe']); |
118 | 118 | Security_user::where('id', $Student->id)->update(['updated_from' => 'doe']); |
119 | 119 | } |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | public function cleanInvalidData($Student) |
123 | 123 | { |
124 | 124 | $Student = (array) $Student; |
125 | - $exist = Examination_student::where('nsid',$Student['nsid'])->count(); |
|
125 | + $exist = Examination_student::where('nsid', $Student['nsid'])->count(); |
|
126 | 126 | |
127 | 127 | $this->uniqueUId = new UniqueUid(); |
128 | 128 | |
129 | - $nsid = ltrim(rtrim($Student['nsid'],'-'),'-'); |
|
130 | - if(!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')){ |
|
129 | + $nsid = ltrim(rtrim($Student['nsid'], '-'), '-'); |
|
130 | + if (!$this->uniqueUId::isValidUniqueId('DBY-898-3J2')) { |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | ->whereRaw('CHAR_LENGTH(nsid) > 11') |
54 | 54 | ->get() |
55 | 55 | ->toArray(); |
56 | - }elseif($type == 'duplicate'){ |
|
56 | + } elseif($type == 'duplicate'){ |
|
57 | 57 | $students = DB::table('security_users') |
58 | 58 | ->where('updated_from', 'doe') |
59 | 59 | ->get() |
60 | 60 | ->toArray(); |
61 | 61 | |
62 | - }elseif($type == 'all'){ |
|
62 | + } elseif($type == 'all'){ |
|
63 | 63 | $students = DB::table('examination_students') |
64 | 64 | ->where('nsid','<>','') |
65 | 65 | ->whereNotNull('nsid') |
66 | 66 | ->get() |
67 | 67 | ->toArray(); |
68 | - }elseif($type == 'lock'){ |
|
68 | + } elseif($type == 'lock'){ |
|
69 | 69 | $students = DB::table('examination_students') |
70 | 70 | ->where('nsid','<>','') |
71 | 71 | ->whereNotNull('nsid') |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $students = array_chunk($students, $this->argument('chunk')); |
80 | 80 | $function = array($this, 'process'); |
81 | 81 | processParallel($function,$students, $this->argument('max'),$type); |
82 | - }else{ |
|
82 | + } else{ |
|
83 | 83 | $this->output->writeln('nothing to process, all are cleaned'); |
84 | 84 | } |
85 | 85 | $this->output->writeln('###########################################------Finished cleaning exam records------###########################################'); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function process($students,$count,$type){ |
89 | 89 | if($type === 'duplicate'){ |
90 | 90 | array_walk($students,array($this,'cleanData')); |
91 | - }elseif($type === 'lock'){ |
|
91 | + } elseif($type === 'lock'){ |
|
92 | 92 | array_walk($students,array($this,'lockData')); |
93 | 93 | } |
94 | 94 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | Institution_student_admission::where('student_id', $Student->id)->delete(); |
114 | 114 | Security_user::where('id', $Student->id)->delete(); |
115 | 115 | $this->output->writeln('cleaned:'. (string)$Student->openemis_no); |
116 | - }else{ |
|
116 | + } else{ |
|
117 | 117 | Institution_student::where('student_id', $Student->id)->update(['updated_from' => 'doe']); |
118 | 118 | Security_user::where('id', $Student->id)->update(['updated_from' => 'doe']); |
119 | 119 | } |