Skip to content

Commit

Permalink
Merge branch 'UAT' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
HarindaVithana authored Mar 28, 2022
2 parents 23c605b + 916ea01 commit 87092e2
Show file tree
Hide file tree
Showing 11 changed files with 401 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Platformer Generated bulk-upload-uat-tag Build
'on':
push:
tags:
- v*
jobs:
build:
runs-on:
- ubuntu-latest
env:
SERVICE_NAME: docker.pkg.github.com/moe-lk/bulk-upload/bulk-upload
CONTAINER_REGISTRY: docker.pkg.github.com
steps:
- uses: actions/checkout@v2
- name: Set Version
id: event-version
run: echo ::set-output name=SOURCE_TAG::${{github.sha}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWORD_5F026685_2D56_4C11_9A6C_4CBB754773C2 }}
- name: Build the Docker image
run: docker build --tag ${SERVICE_NAME}:${{steps.event-version.outputs.SOURCE_TAG }} --file Dockerfile .
- name: GitHub Image Push
run: docker push $SERVICE_NAME:${{steps.event-version.outputs.SOURCE_TAG }}
- name: Platformer Deploy
uses: platformer-com/build-deploy-action@v1
with:
org-id: ${{secrets.ORG_ID_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
project-id: ${{secrets.PROJECT_ID_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
token: ${{secrets.AUTOGENERATED_CICD_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
image-name: ${{env.SERVICE_NAME}}
tag: ${{steps.event-version.outputs.SOURCE_TAG }}
container-id: 33d05e0d-7144-421d-afc3-f01813f9ff7e
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Platformer Generated bulk-upload-uat-tag Build
'on':
push:
tags:
- v*
jobs:
build:
runs-on:
- ubuntu-latest
env:
SERVICE_NAME: docker.pkg.github.com/moe-lk/bulk-upload/bulk-upload
CONTAINER_REGISTRY: docker.pkg.github.com
steps:
- uses: actions/checkout@v2
- name: Set Version
id: event-version
run: echo ::set-output name=SOURCE_TAG::${{github.sha}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWORD_83326795_7A09_4CC2_B7CB_8F5B4AE33674 }}
- name: Build the Docker image
run: docker build --tag ${SERVICE_NAME}:${{steps.event-version.outputs.SOURCE_TAG }} --file Dockerfile .
- name: GitHub Image Push
run: docker push $SERVICE_NAME:${{steps.event-version.outputs.SOURCE_TAG }}
- name: Platformer Deploy
uses: platformer-com/build-deploy-action@v1
with:
org-id: ${{secrets.ORG_ID_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
project-id: ${{secrets.PROJECT_ID_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
token: ${{secrets.AUTOGENERATED_CICD_38BBBF6B_404D_4E3A_8C90_5AB3EE4DDF96}}
image-name: ${{env.SERVICE_NAME}}
tag: ${{steps.event-version.outputs.SOURCE_TAG }}
container-id: 33d05e0d-7144-421d-afc3-f01813f9ff7e
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Platformer Generated bulk-upload-uat-workflow Build
'on':
push:
branches:
- UAT
jobs:
build:
runs-on:
- ubuntu-latest
env:
SERVICE_NAME: docker.pkg.github.com/moe-lk/bulk-upload/bulk-upload
CONTAINER_REGISTRY: docker.pkg.github.com
steps:
- uses: actions/checkout@v2
- name: Set Version
id: event-version
run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/heads/}-${{github.sha}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWORD_B02B6AE4_58BF_45B1_97EA_60D7D937E37E }}
- name: Build the Docker image
run: docker build --tag ${SERVICE_NAME}:${{steps.event-version.outputs.SOURCE_TAG }} --file Dockerfile .
- name: GitHub Image Push
run: docker push $SERVICE_NAME:${{steps.event-version.outputs.SOURCE_TAG }}
- name: Platformer Deploy
uses: platformer-com/build-deploy-action@v1
with:
org-id: ${{secrets.ORG_ID_767EF5C0_2F2A_4CAE_A434_126B65702226}}
project-id: ${{secrets.PROJECT_ID_767EF5C0_2F2A_4CAE_A434_126B65702226}}
token: ${{secrets.AUTOGENERATED_CICD_767EF5C0_2F2A_4CAE_A434_126B65702226}}
image-name: ${{env.SERVICE_NAME}}
tag: ${{steps.event-version.outputs.SOURCE_TAG }}
container-id: f8781cf8-cddc-4150-bed7-b3839b29b423
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ RUN chgrp -R www-data storage/ && \
RUN composer install

RUN sudo groupadd docker
RUN sudo usermod -aG docker user

RUN chmod -R 775 storage
RUN chmod -R 775 bootstrap/cache
RUN sudo usermod -aG docker devuser

RUN sudo chown -R $user:www-data storage
RUN sudo chown -R $user:www-data bootstrap/cache

EXPOSE 80
86 changes: 86 additions & 0 deletions app/Console/Commands/RollbackStudentFromInstitutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Database\Eloquent\Builder;

use App\Models\Institution_grade;
use PhpParser\Node\Stmt\TryCatch;

class RollbackStudentFromInstitutes extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admission:rollback {institution}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Rollback promoted flag in institution_grades table to 2019';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
/*
* Set back the promoted flag in institution_grades table to 2019.
* 1. Get all the values of promoted field by each record
* 2. Assign all the records to an array
* 3. Loop through all the indexes of the array and check whether the promoted values are equal to 2019
* 4. If not, set them to 2019
*/

try {
/*
* Getting all the records by corresponding institute_id.
*/
$this->info('Fetching all the records...');
$institution_grades = DB::select('select * from institution_grades where institution_id = :id', ['id' => $this->argument('institution')]);

/*
* First check whether the array is not empty
* Then loop though all the records and check the promoted value
* If the promoted value is equal to 2019 keep it as it is otherwise set it back to 2019
*/
if (!empty($institution_grades)) {

$this->info('Fetched ' . count($institution_grades) . ' records');

foreach ($institution_grades as $institute_grade) {
if ($institute_grade->promoted == "2019") {
$this->info('Promoted year have already set to 2019');
} else {
$this->info('Updating record =======================================');
DB::update("update institution_grades set promoted ='2019' where institution_id = ?", [$this->argument('institution')]);
$this->info('Record updated ========================================');
}
}
} else {
$this->info('No results!');
}
} catch (\Exception $e) {
return $e->getMessage();
}
}
}
121 changes: 121 additions & 0 deletions app/Console/Commands/RunAddStudentsToInstitutions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Institution_class_student;
use App\Models\Institution_class_subject;
use App\Models\Institution_student_admission;
use App\Models\Institution_student;
use App\Models\Institution;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class RunAddStudentsToInstitutions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admission:students {institution}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Add approved students data to indtitution_student table';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->count = 0;
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{

$institution = Institution::where([
'id' => $this->argument('institution')
])->first();

if(!is_null($institution)){
DB::enableQueryLog();
try {
$this->info('adding missing students to the institution ' . $institution->name);
$approvedstudent = Institution_student_admission::select('institution_student_admission.*')
->leftJoin('institution_students', 'institution_student_admission.student_id', '=', 'institution_students.student_id')
->whereIn('status_id',[121,122,123,124])
->where('institution_student_admission.institution_id',$institution->id)->get()->toArray();

$approvedstudent = array_chunk($approvedstudent, 50);

array_walk($approvedstudent, array($this, 'addStudents'));

}catch (\Exception $e) {
Log::error($e);
}
}
}

protected function addStudents($approvedstudent){
array_walk($approvedstudent,array($this,'addStudent'));
}

protected function addStudent($approvedstudent){
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
Log::info($approvedstudent);
// sleep(1);
if((Institution_student::isDuplicated($approvedstudent) == 0)){
dd($approvedstudent);
$this->count += 1;
$this->student = $approvedstudent ;
try{
$output->writeln($approvedstudent['student_id']."Updated");
Institution_student::create([
'student_status_id' => 1,
'student_id' => $approvedstudent['student_id'],
'education_grade_id' => $approvedstudent['education_grade_id'],
'academic_period_id' => $approvedstudent['academic_period_id'],
'start_date' => $approvedstudent['start_date'],
'start_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['start_date'])->year , // $approvedstudent['start_date']->format('Y'),
'end_date' => $approvedstudent['end_date'],
'end_year' => \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $approvedstudent['end_date'])->year , //$approvedstudent['end_date']->format('Y'),
'institution_id' => $approvedstudent['institution_id'],
'admission_id' => $approvedstudent['admission_id'],
'created_user_id' => $approvedstudent['created_user_id'],
]);
if(!is_null($approvedstudent['institution_class_id'])){
Institution_class_student::create([
'student_id' => $approvedstudent['student_id'],
'institution_class_id' => $approvedstudent['institution_class_id'],
'education_grade_id' => $approvedstudent['education_grade_id'],
'academic_period_id' => $approvedstudent['academic_period_id'],
'institution_id' =>$approvedstudent['institution_id'],
'student_status_id' => 1,
'created_user_id' => $approvedstudent['created_user_id'],
]);
}
}catch (\Exception $e){
echo $e->getMessage();
}
}
$output->writeln('
####################################################
Total number of students updated : '.$this->count.'
# #
####################################################' );
}
}

Loading

0 comments on commit 87092e2

Please sign in to comment.