Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nizar dev #253

Open
wants to merge 3 commits into
base: UAT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions app/Console/Commands/ProcessTerminatedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function handle()
$files = $this->getFiles();
try {
if(!empty($files)){
$this->process($files);
array_walk($files,array($this,'process'));
unset($files);
exit();

Expand All @@ -71,21 +71,14 @@ protected function getFiles(){
$files = Upload::where('is_processed', '=', 3)
->where('is_email_sent','=',0)
->where('updated_at', '<=', Carbon::now()->tz('Asia/Colombo')->subHours(3))
->limit(1)
->limit(50)
->get()->toArray();
if(!empty($files)){
DB::beginTransaction();
DB::table('uploads')
->where('id', $files[0]['id'])
->update(['is_processed' => 3,'updated_at' => now()]);
DB::commit();
}
return $files;
}

protected function process($file){
$time = Carbon::now()->tz('Asia/Colombo');
$this->processSheet($file[0]);
$this->processSheet($file);
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$now = Carbon::now()->tz('Asia/Colombo');
$output->writeln('=============== Time taken to batch ' .$now->diffInMinutes($time));
Expand All @@ -95,7 +88,6 @@ protected function process($file){
protected function processSheet($file){
$this->startTime = Carbon::now()->tz('Asia/Colombo');
$user = User::find($file['security_user_id']);
$this->checkNode($file);
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln('##########################################################################################################################');
$output->writeln('Processing the file: '.$file['filename']);
Expand Down
29 changes: 16 additions & 13 deletions app/Console/Commands/RunAddApprovedStudents.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function handle()
$this->info('adding missing students to the admission ' . $institution->name);
$allApprovedStudents = Institution_student_admission::where([
'status_id' => 124,
'institution_id' => $institution->institution_id
'institution_id' => $institution->id
])->get()->toArray();
$allApprovedStudents = array_chunk($allApprovedStudents, 50);
array_walk($allApprovedStudents, array($this, 'addStudents'));
Expand All @@ -74,7 +74,7 @@ protected function addStudent($student){
// dd(Institution_class_student::isDuplicated($student));
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
sleep(1);
if(!(Institution_class_student::isDuplicated($student) > 0)){
if(!(Institution_student::isDuplicated($student))){
$this->count += 1;
$this->student = $student ;
try{
Expand All @@ -92,17 +92,20 @@ protected function addStudent($student){
'created_user_id' => $student['created_user_id'],
]);

if(!is_null($student['institution_class_id'])){
Institution_class_student::create([
'student_id' => $student['student_id'],
'institution_class_id' => $student['institution_class_id'],
'education_grade_id' => $student['education_grade_id'],
'academic_period_id' => $student['academic_period_id'],
'institution_id' =>$student['institution_id'],
'student_status_id' => 1,
'created_user_id' => $student['created_user_id'],
]);
}
if(!(Institution_class_student::isDuplicated($student))){
if(!is_null($student['institution_class_id'])){
Institution_class_student::create([
'student_id' => $student['student_id'],
'institution_class_id' => $student['institution_class_id'],
'education_grade_id' => $student['education_grade_id'],
'academic_period_id' => $student['academic_period_id'],
'institution_id' =>$student['institution_id'],
'student_status_id' => 1,
'created_user_id' => $student['created_user_id'],
]);
}
}

$output->writeln('
####################################################
Total number of students updated : '.$this->count.'
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Institution_class_student.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function isDuplicated($inputs){

$exists = self::where('student_id','=',$inputs['student_id'])
->where('institution_class_id',$inputs['institution_class_id'])
->count();
->exist();

return $exists;
}
Expand Down
8 changes: 6 additions & 2 deletions app/Models/Institution_student.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ public static function boot()
*/
public static function isDuplicated($inputs){

$exists = self::where('student_id','=',$inputs['student_id'])->count();

$exists = self::where('student_id','=',$inputs['student_id'])
->where('institution_id',$inputs['institution_id'])
->where('academic_period_id',$inputs['academic_period_id'])
->exist();

return $exists;
}
Expand Down Expand Up @@ -111,4 +113,6 @@ public function getStudentListToPromote($institutionGrade, $academicPeriod){
->where('institution_students.academic_period_id', $academicPeriod->id)->get()->toArray();
}



}