Skip to content

Commit

Permalink
Controllers: Core: Fixup database CRUD order
Browse files Browse the repository at this point in the history
- After update table scheme for appLogs, some of controller need to be updated for
database insert scheme for column order. To fix issue eloquent transaction error
- Re-order table schema insert for htmltopdf scheme after new database scheme update
- Set default value for created_at as timestamp by default

Signed-off-by: Dicky Herlambang (花) <herlambangdicky5@gmail.com>
  • Loading branch information
Nicklas373 committed May 12, 2024
1 parent bbbe93d commit 89bd7c1
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 277 deletions.
48 changes: 24 additions & 24 deletions app/Http/Controllers/Api/Core/compressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => $validator->messages(),
'errApiReason' => null
'errStatus' => null
]);
NotificationHelper::Instance()->sendErrNotify(null,null, $uuid, 'FAIL','compress','PDF Compression failed !',$validator->messages());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -143,7 +143,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -162,7 +162,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on StartException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on StartException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -213,7 +213,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -232,7 +232,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on AuthException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on AuthException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -283,7 +283,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -302,7 +302,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on UploadException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on UploadException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -353,7 +353,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -372,7 +372,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on ProcessException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on ProcessException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -423,7 +423,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -443,7 +443,7 @@ public function compress(Request $request) {
->update([
'processId' => $Nuuid,
'errReason' => 'iLovePDF API Error !, Catch on DownloadException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on DownloadException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -494,7 +494,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -513,7 +513,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on TaskException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on TaskException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -564,7 +564,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName,
Expand All @@ -584,7 +584,7 @@ public function compress(Request $request) {
->update([
'processId' => $Nuuid,
'errReason' => 'iLovePDF API Error !, Catch on PathException',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on PathException', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -635,7 +635,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName.'.pdf',
Expand All @@ -654,7 +654,7 @@ public function compress(Request $request) {
->where('processId', '=', $Nuuid)
->update([
'errReason' => 'iLovePDF API Error !, Catch on Exception',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName, $fileSize, $Nuuid, 'FAIL', 'compress', 'iLovePDF API Error !, Catch on Exception', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -709,7 +709,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $newFileNameWithoutExtension.'.pdf',
Expand Down Expand Up @@ -746,7 +746,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $Nuuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => $currentFileName.'.pdf',
Expand All @@ -765,7 +765,7 @@ public function compress(Request $request) {
->where('processId', '=', $uuid)
->update([
'errReason' => 'Failed to download file from iLovePDF API !',
'errApiReason' => null
'errStatus' => null
]);
NotificationHelper::Instance()->sendErrNotify($currentFileName.'.pdf', $newFileSize, $Nuuid, 'FAIL', 'compress', 'Failed to download file from iLovePDF API !', null);
return $this->returnCoreMessage(
Expand Down Expand Up @@ -876,7 +876,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'Archive processing failure',
'errApiReason' => $e->getMessage()
'errStatus' => $e->getMessage()
]);
NotificationHelper::Instance()->sendErrNotify($randomizePdfFileName.'.zip', null, $uuid, 'FAIL', 'compress', 'Failed archiving PDF files !', $e->getMessage());
return $this->returnCoreMessage(
Expand Down Expand Up @@ -927,7 +927,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'PDF Compress failed',
'errApiReason' => 'Processed file are not same with total file, processed: '.$procFile.' totalFile: '.$loopCount
'errStatus' => 'Processed file are not same with total file, processed: '.$procFile.' totalFile: '.$loopCount
]);
NotificationHelper::Instance()->sendErrNotify($randomizePdfFileName.'.zip', null, $uuid, 'FAIL', 'compress', 'PDF Compress failed !', 'Processed file are not same with total file, processed: '.$procFile.' totalFile: '.$loopCount);
return $this->returnCoreMessage(
Expand Down Expand Up @@ -979,7 +979,7 @@ public function compress(Request $request) {
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => null,
'errApiReason' => null
'errStatus' => null
]);
DB::table('pdfCompress')->insert([
'fileName' => null,
Expand All @@ -997,7 +997,7 @@ public function compress(Request $request) {
->update([
'processId' => $uuid,
'errReason' => 'PDF failed to upload !',
'errApiReason' => null
'errStatus' => null
]);
NotificationHelper::Instance()->sendErrNotify(null, null, $uuid, 'FAIL', 'compress', 'PDF failed to upload !', null);
return $this->returnCoreMessage(
Expand Down

0 comments on commit 89bd7c1

Please sign in to comment.