Skip to content

Commit

Permalink
v3.3.9 20241111 [Frontend Module] (#280)
Browse files Browse the repository at this point in the history
Recent changelog:

- [Helpers: Check to all related column while generate
UUID](e45a339)
- [Exceptions: Handler: Use more proper function to generate
UUID](bc6fd68)
- [Resources: kao-logic: Minor
updates](ef1ded2)
  • Loading branch information
Nicklas373 authored Nov 11, 2024
2 parents e610de8 + 05a0b80 commit 4b42aae
Show file tree
Hide file tree
Showing 17 changed files with 376 additions and 211 deletions.
4 changes: 2 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function register(): void

public function render($request, Throwable $exception)
{
$uuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'processId');
$Muuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'groupId');
$uuid = AppHelper::Instance()->generateUniqueUuid(appLogModel::class, 'processId');
$Muuid = AppHelper::Instance()->generateUniqueUuid(appLogModel::class, 'groupId');

appLogModel::create([
'processId' => $uuid,
Expand Down
53 changes: 28 additions & 25 deletions app/Helpers/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
namespace App\Helpers;

use App\Models\appLogModel;
use App\Models\jobLogModel;
use App\Models\notifyLogModel;
use Carbon\Carbon;
use App\Models\compressModel;
use App\Models\cnvModel;
use App\Models\htmlModel;
use App\Models\mergeModel;
use App\Models\splitModel;
use App\Models\watermarkModel;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Ramsey\Uuid\Uuid;
Expand All @@ -29,32 +35,29 @@ function getCurrentTimeZone() {
return $currentDateTime;
}

function generateSingleUniqueUuid($customModel, $customColumn) {
$startProc = Carbon::now()->format('Y-m-d H:i:s');
$uniqueID = Uuid::uuid4();
// do {
// $uniqueID = Uuid::uuid4();
// } while (
// $customModel::where($customColumn, $uniqueID)->exists()
// );
$end = Carbon::now();
$duration = $end->diffInSeconds(Carbon::parse($startProc));
Log::Info('New single unique UUID has been generated with response time: '.$duration.' seconds');
return $uniqueID->toString();
}

function generateUniqueUuid($customModel, $customColumn) {
$startProc = Carbon::now()->format('Y-m-d H:i:s');
$uniqueID = Uuid::uuid4();
// do {
// $uniqueID = Uuid::uuid4();
// } while (
// appLogModel::where($customColumn, $uniqueID)->exists() ||
// $customModel::where($customColumn, $uniqueID)->exists()
// );
$end = Carbon::now();
$duration = $end->diffInSeconds(Carbon::parse($startProc));
Log::Info('New unique UUID has been generated with response time: '.$duration.' seconds');
// if ($customColumn !== 'processId') {
// do {
// $uniqueID = Uuid::uuid4();
// } while (
// $customModel::where($customColumn, $uniqueID)->exists()
// );
// } else {
// do {
// $uniqueID = Uuid::uuid4();
// } while (
// appLogModel::where($customColumn, $uniqueID)->exists() ||
// jobLogModel::where($customColumn, $uniqueID)->exists() ||
// notifyLogModel::where($customColumn, $uniqueID)->exists() ||
// compressModel::where($customColumn, $uniqueID)->exists() ||
// cnvModel::where($customColumn, $uniqueID)->exists() ||
// htmlModel::where($customColumn, $uniqueID)->exists() ||
// mergeModel::where($customColumn, $uniqueID)->exists() ||
// splitModel::where($customColumn, $uniqueID)->exists() ||
// watermarkModel::where($customColumn, $uniqueID)->exists()
// );
// }
return $uniqueID->toString();
}

Expand Down
31 changes: 31 additions & 0 deletions app/Models/cnvModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class cnvModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfConvert';
protected $primaryKey = 'cnvId';
protected $keyType = 'string';

protected $fillable = [
'fileName',
'fileSize',
'container',
'imgExtract',
'result',
'isBatch',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
31 changes: 31 additions & 0 deletions app/Models/compressModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class compressModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $primaryKey = 'compressId';
protected $table = 'pdfCompress';
protected $keyType = 'string';

protected $fillable = [
'fileName',
'fileSize',
'compFileSize',
'compMethod',
'result',
'isBatch',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
30 changes: 30 additions & 0 deletions app/Models/htmlModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class htmlModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfHtml';
protected $primaryKey = 'htmlId';
protected $keyType = 'string';

protected $fillable = [
'urlName',
'urlMargin',
'urlOrientation',
'urlSinglePage',
'urlSize',
'result',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
29 changes: 29 additions & 0 deletions app/Models/mergeModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class mergeModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfMerge';
protected $primaryKey = 'mergeId';
protected $keyType = 'string';

protected $fillable = [
'fileName',
'fileSize',
'result',
'isBatch',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
36 changes: 36 additions & 0 deletions app/Models/splitModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class splitModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfSplit';
protected $primaryKey = 'splitId';
protected $keyType = 'string';

protected $fillable = [
'fileName',
'fileSize',
'fromPage',
'toPage',
'customPage',
'fixedPage',
'fixedPageRange',
'mergePDF',
'action',
'result',
'isBatch',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
40 changes: 40 additions & 0 deletions app/Models/watermarkModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class watermarkModel extends Model
{
use HasFactory;

protected $connection = 'pgsql';
protected $table = 'pdfWatermark';
protected $primaryKey = 'watermarkId';
protected $keyType = 'string';

protected $fillable = [
'fileName',
'fileSize',
'watermarkFontFamily',
'watermarkFontStyle',
'watermarkFontSize',
'watermarkFontTransparency',
'watermarkImage',
'watermarkLayout',
'watermarkMosaic',
'watermarkRotation',
'watermarkStyle',
'watermarkText',
'watermarkPage',
'result',
'isBatch',
'batchName',
'groupId',
'processId',
'procStartAt',
'procEndAt',
'procDuration'
];
}
34 changes: 17 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4b42aae

Please sign in to comment.