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

S40(12) DevOps - System load testing [jp-0004] #205

Merged
merged 3 commits into from
Jun 9, 2023
Merged
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
32 changes: 28 additions & 4 deletions app/Imports/CharitiesImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CharitiesImport implements ToCollection, WithStartRow, WithChunkReading, W
protected $created_count;
protected $updated_count;
protected $skipped_count;
protected $created_by_id;

public function __construct($history_id)
{
Expand Down Expand Up @@ -77,9 +78,11 @@ public function collection(Collection $rows)
$old_charity = Charity::where('registration_number', $row[0])
->first();

if ($old_charity->charity_status == 'Pending-Dissolution') {
if ($old_charity && $old_charity->charity_status == 'Pending-Dissolution') {
if (($this->created_count + $this->updated_count + $this->skipped_count) <= 500) {
$this->logMessage('[SKIPPED - Pending-Dissolution] ' . json_encode($old_charity->only(['id','registration_number','charity_name','charity_status', 'effective_date_of_status'])) );
}
$this->skipped_count += 1;
$this->logMessage('[SKIPPED - Pending-Dissolution] ' . json_encode($old_charity->only(['id','registration_number','charity_name','charity_status', 'effective_date_of_status'])) );
continue;
}

Expand All @@ -103,12 +106,25 @@ public function collection(Collection $rows)

if ($charity->wasRecentlyCreated) {
// $this->logMessage('[CREATED] ' . json_encode($row) );
$this->logMessage('[CREATED] ' . json_encode( $pledge->only(['id','registration_number','charity_name','charity_status', 'effective_date_of_status'])));
if (($this->created_count + $this->updated_count + $this->skipped_count) <= 500) {
$this->logMessage('[CREATED] ' . json_encode( $charity->only(['id','registration_number','charity_name','charity_status', 'effective_date_of_status'])));
}
$this->created_count += 1;

$charity->created_by_id = $this->created_by_id;
$charity->updated_by_id = $this->created_by_id;
$charity->save();

} elseif ($charity->wasChanged() ) {

$charity->updated_by_id = $this->created_by_id;
$charity->save();

$changes = $charity->getChanges();
unset($changes["updated_at"]);
$this->logMessage('[UPDATED] on RN# ' . $charity->registration_number . ' - ' . json_encode($changes) );
if (($this->created_count + $this->updated_count + $this->skipped_count) <= 500) {
$this->logMessage('[UPDATED] on RN# ' . $charity->registration_number . ' - ' . json_encode($changes) );
}
$this->updated_count += 1;
} else {
// No Action
Expand Down Expand Up @@ -168,6 +184,8 @@ public function registerEvents(): array

$history = \App\Models\ProcessHistory::where('id', $this->history_id)->first();

$this->created_by_id = $history->created_by_id;

$message = 'Process ID : ' . $this->history_id . PHP_EOL;
$message .= 'Process parameters : ' . ($history ? $history->parameters : '') . PHP_EOL;
$message .= PHP_EOL;
Expand Down Expand Up @@ -243,6 +261,12 @@ public function registerEvents(): array
$message .= 'Total Updated (Not-in-CRA) count : ' . $not_in_cra_count . PHP_EOL;
$message .= 'Total Skipped count : ' . $this->skipped_count . PHP_EOL;

if (($this->created_count + $this->updated_count + $this->skipped_count) > 500) {
$message .= PHP_EOL;
$message .= 'Note: more than 500 changes found, only first 500 detail were logged in the file.' . PHP_EOL;
$message .= PHP_EOL;
}


$history = \App\Models\ProcessHistory::where('id', $this->history_id)->first();

Expand Down
145 changes: 145 additions & 0 deletions database/seeders/SampleUsersSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\Organization;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Permission;

class SampleUsersSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// User Creation

$users = [
[ 'id'=>101, 'email'=>'[email protected]', 'name'=>'Employee 101', 'emplid' => '005829', ],
[ 'id'=>102, 'email'=>'[email protected]', 'name'=>'Employee 102', 'emplid' => '010036', ],
[ 'id'=>103, 'email'=>'[email protected]', 'name'=>'Employee 103', 'emplid' => '013238', ],
[ 'id'=>104, 'email'=>'[email protected]', 'name'=>'Employee 104', 'emplid' => '016603', ],
[ 'id'=>105, 'email'=>'[email protected]', 'name'=>'Employee 105', 'emplid' => '018522', ],
[ 'id'=>106, 'email'=>'[email protected]', 'name'=>'Employee 106', 'emplid' => '026277', ],
[ 'id'=>107, 'email'=>'[email protected]', 'name'=>'Employee 107', 'emplid' => '027290', ],
[ 'id'=>108, 'email'=>'[email protected]', 'name'=>'Employee 108', 'emplid' => '037562', ],
[ 'id'=>109, 'email'=>'[email protected]', 'name'=>'Employee 109', 'emplid' => '044030', ],
[ 'id'=>110, 'email'=>'[email protected]', 'name'=>'Employee 110', 'emplid' => '055564', ],
[ 'id'=>111, 'email'=>'[email protected]', 'name'=>'Employee 111', 'emplid' => '056965', ],
[ 'id'=>112, 'email'=>'[email protected]', 'name'=>'Employee 112', 'emplid' => '060242', ],
[ 'id'=>113, 'email'=>'[email protected]', 'name'=>'Employee 113', 'emplid' => '061205', ],
[ 'id'=>114, 'email'=>'[email protected]', 'name'=>'Employee 114', 'emplid' => '069956', ],
[ 'id'=>115, 'email'=>'[email protected]', 'name'=>'Employee 115', 'emplid' => '085102', ],
[ 'id'=>116, 'email'=>'[email protected]', 'name'=>'Employee 116', 'emplid' => '097590', ],
[ 'id'=>117, 'email'=>'[email protected]', 'name'=>'Employee 117', 'emplid' => '098773', ],
[ 'id'=>118, 'email'=>'[email protected]', 'name'=>'Employee 118', 'emplid' => '098998', ],
[ 'id'=>119, 'email'=>'[email protected]', 'name'=>'Employee 119', 'emplid' => '099489', ],
[ 'id'=>120, 'email'=>'[email protected]', 'name'=>'Employee 120', 'emplid' => '099819', ],
[ 'id'=>121, 'email'=>'[email protected]', 'name'=>'Employee 121', 'emplid' => '099992', ],
[ 'id'=>122, 'email'=>'[email protected]', 'name'=>'Employee 122', 'emplid' => '100987', ],
[ 'id'=>123, 'email'=>'[email protected]', 'name'=>'Employee 123', 'emplid' => '101014', ],
[ 'id'=>124, 'email'=>'[email protected]', 'name'=>'Employee 124', 'emplid' => '104181', ],
[ 'id'=>125, 'email'=>'[email protected]', 'name'=>'Employee 125', 'emplid' => '104191', ],
[ 'id'=>126, 'email'=>'[email protected]', 'name'=>'Employee 126', 'emplid' => '105083', ],
[ 'id'=>127, 'email'=>'[email protected]', 'name'=>'Employee 127', 'emplid' => '105926', ],
[ 'id'=>128, 'email'=>'[email protected]', 'name'=>'Employee 128', 'emplid' => '106994', ],
[ 'id'=>129, 'email'=>'[email protected]', 'name'=>'Employee 129', 'emplid' => '107460', ],
[ 'id'=>130, 'email'=>'[email protected]', 'name'=>'Employee 130', 'emplid' => '108318', ],
[ 'id'=>131, 'email'=>'[email protected]', 'name'=>'Employee 131', 'emplid' => '110022', ],
[ 'id'=>132, 'email'=>'[email protected]', 'name'=>'Employee 132', 'emplid' => '110706', ],
[ 'id'=>133, 'email'=>'[email protected]', 'name'=>'Employee 133', 'emplid' => '111179', ],
[ 'id'=>134, 'email'=>'[email protected]', 'name'=>'Employee 134', 'emplid' => '112987', ],
[ 'id'=>135, 'email'=>'[email protected]', 'name'=>'Employee 135', 'emplid' => '120539', ],
[ 'id'=>136, 'email'=>'[email protected]', 'name'=>'Employee 136', 'emplid' => '122510', ],
[ 'id'=>137, 'email'=>'[email protected]', 'name'=>'Employee 137', 'emplid' => '123284', ],
[ 'id'=>138, 'email'=>'[email protected]', 'name'=>'Employee 138', 'emplid' => '125662', ],
[ 'id'=>139, 'email'=>'[email protected]', 'name'=>'Employee 139', 'emplid' => '126390', ],
[ 'id'=>140, 'email'=>'[email protected]', 'name'=>'Employee 140', 'emplid' => '127365', ],
[ 'id'=>141, 'email'=>'[email protected]', 'name'=>'Employee 141', 'emplid' => '128123', ],
[ 'id'=>142, 'email'=>'[email protected]', 'name'=>'Employee 142', 'emplid' => '129245', ],
[ 'id'=>143, 'email'=>'[email protected]', 'name'=>'Employee 143', 'emplid' => '130597', ],
[ 'id'=>144, 'email'=>'[email protected]', 'name'=>'Employee 144', 'emplid' => '131310', ],
[ 'id'=>145, 'email'=>'[email protected]', 'name'=>'Employee 145', 'emplid' => '132458', ],
[ 'id'=>146, 'email'=>'[email protected]', 'name'=>'Employee 146', 'emplid' => '132544', ],
[ 'id'=>147, 'email'=>'[email protected]', 'name'=>'Employee 147', 'emplid' => '133818', ],
[ 'id'=>148, 'email'=>'[email protected]', 'name'=>'Employee 148', 'emplid' => '134625', ],
[ 'id'=>149, 'email'=>'[email protected]', 'name'=>'Employee 149', 'emplid' => '135127', ],
[ 'id'=>150, 'email'=>'[email protected]', 'name'=>'Employee 150', 'emplid' => '137130', ],
[ 'id'=>151, 'email'=>'[email protected]', 'name'=>'Employee 151', 'emplid' => '137319', ],
[ 'id'=>152, 'email'=>'[email protected]', 'name'=>'Employee 152', 'emplid' => '137942', ],
[ 'id'=>153, 'email'=>'[email protected]', 'name'=>'Employee 153', 'emplid' => '138140', ],
[ 'id'=>154, 'email'=>'[email protected]', 'name'=>'Employee 154', 'emplid' => '138174', ],
[ 'id'=>155, 'email'=>'[email protected]', 'name'=>'Employee 155', 'emplid' => '140618', ],
[ 'id'=>156, 'email'=>'[email protected]', 'name'=>'Employee 156', 'emplid' => '140717', ],
[ 'id'=>157, 'email'=>'[email protected]', 'name'=>'Employee 157', 'emplid' => '140903', ],
[ 'id'=>158, 'email'=>'[email protected]', 'name'=>'Employee 158', 'emplid' => '140996', ],
[ 'id'=>159, 'email'=>'[email protected]', 'name'=>'Employee 159', 'emplid' => '142516', ],
[ 'id'=>160, 'email'=>'[email protected]', 'name'=>'Employee 160', 'emplid' => '143222', ],
[ 'id'=>161, 'email'=>'[email protected]', 'name'=>'Employee 161', 'emplid' => '143836', ],
[ 'id'=>162, 'email'=>'[email protected]', 'name'=>'Employee 162', 'emplid' => '144511', ],
[ 'id'=>163, 'email'=>'[email protected]', 'name'=>'Employee 163', 'emplid' => '144835', ],
[ 'id'=>164, 'email'=>'[email protected]', 'name'=>'Employee 164', 'emplid' => '145336', ],
[ 'id'=>165, 'email'=>'[email protected]', 'name'=>'Employee 165', 'emplid' => '146293', ],
[ 'id'=>166, 'email'=>'[email protected]', 'name'=>'Employee 166', 'emplid' => '147367', ],
[ 'id'=>167, 'email'=>'[email protected]', 'name'=>'Employee 167', 'emplid' => '148407', ],
[ 'id'=>168, 'email'=>'[email protected]', 'name'=>'Employee 168', 'emplid' => '148981', ],
[ 'id'=>169, 'email'=>'[email protected]', 'name'=>'Employee 169', 'emplid' => '149964', ],
[ 'id'=>170, 'email'=>'[email protected]', 'name'=>'Employee 170', 'emplid' => '151155', ],
[ 'id'=>171, 'email'=>'[email protected]', 'name'=>'Employee 171', 'emplid' => '151721', ],
[ 'id'=>172, 'email'=>'[email protected]', 'name'=>'Employee 172', 'emplid' => '152576', ],
[ 'id'=>173, 'email'=>'[email protected]', 'name'=>'Employee 173', 'emplid' => '154168', ],
[ 'id'=>174, 'email'=>'[email protected]', 'name'=>'Employee 174', 'emplid' => '154280', ],
[ 'id'=>175, 'email'=>'[email protected]', 'name'=>'Employee 175', 'emplid' => '156509', ],
[ 'id'=>176, 'email'=>'[email protected]', 'name'=>'Employee 176', 'emplid' => '157903', ],
[ 'id'=>177, 'email'=>'[email protected]', 'name'=>'Employee 177', 'emplid' => '157911', ],
[ 'id'=>178, 'email'=>'[email protected]', 'name'=>'Employee 178', 'emplid' => '158816', ],
[ 'id'=>179, 'email'=>'[email protected]', 'name'=>'Employee 179', 'emplid' => '158864', ],
[ 'id'=>180, 'email'=>'[email protected]', 'name'=>'Employee 180', 'emplid' => '159065', ],
[ 'id'=>181, 'email'=>'[email protected]', 'name'=>'Employee 181', 'emplid' => '165705', ],
[ 'id'=>182, 'email'=>'[email protected]', 'name'=>'Employee 182', 'emplid' => '167254', ],
[ 'id'=>183, 'email'=>'[email protected]', 'name'=>'Employee 183', 'emplid' => '170161', ],
[ 'id'=>184, 'email'=>'[email protected]', 'name'=>'Employee 184', 'emplid' => '170591', ],
[ 'id'=>185, 'email'=>'[email protected]', 'name'=>'Employee 185', 'emplid' => '171040', ],
[ 'id'=>186, 'email'=>'[email protected]', 'name'=>'Employee 186', 'emplid' => '171123', ],
[ 'id'=>187, 'email'=>'[email protected]', 'name'=>'Employee 187', 'emplid' => '171229', ],
[ 'id'=>188, 'email'=>'[email protected]', 'name'=>'Employee 188', 'emplid' => '171311', ],
[ 'id'=>189, 'email'=>'[email protected]', 'name'=>'Employee 189', 'emplid' => '171902', ],
[ 'id'=>190, 'email'=>'[email protected]', 'name'=>'Employee 190', 'emplid' => '174089', ],
[ 'id'=>191, 'email'=>'[email protected]', 'name'=>'Employee 191', 'emplid' => '174302', ],
[ 'id'=>192, 'email'=>'[email protected]', 'name'=>'Employee 192', 'emplid' => '174932', ],
[ 'id'=>193, 'email'=>'[email protected]', 'name'=>'Employee 193', 'emplid' => '175217', ],
[ 'id'=>194, 'email'=>'[email protected]', 'name'=>'Employee 194', 'emplid' => '180151', ],
[ 'id'=>195, 'email'=>'[email protected]', 'name'=>'Employee 195', 'emplid' => '187738', ],
[ 'id'=>196, 'email'=>'[email protected]', 'name'=>'Employee 196', 'emplid' => '192011', ],
[ 'id'=>197, 'email'=>'[email protected]', 'name'=>'Employee 197', 'emplid' => '192018', ],
[ 'id'=>198, 'email'=>'[email protected]', 'name'=>'Employee 198', 'emplid' => '192042', ],
[ 'id'=>199, 'email'=>'[email protected]', 'name'=>'Employee 199', 'emplid' => '192048', ],
[ 'id'=>200, 'email'=>'[email protected]', 'name'=>'Employee 200', 'emplid' => '192055', ],
];

$organization = Organization::where('code','GOV')->first();

foreach ($users as $user) {

User::updateOrCreate([
'email' => $user['email'],
], [
'id' => $user['id'],
'name' => $user['name'],
'password' => '$2y$10$AyzSQf4vtA/sEFXG1OWdJ.OqoOmkTNpVl4m.u9np9UE/j1HnJa0Ti',
'source_type' => 'LCL',
'organization_id' => $organization ? $organization->id : null,
'emplid' => $user['emplid'],
]);

}

}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@bcgov/bc-sans": "^1.0.1",
"@fortawesome/fontawesome-free": "^5.15.4",
"admin-lte": "^3.1.0"
"admin-lte": "^3.1.0",
"icheck-bootstrap": "^3.0.1"
}
}
Loading