Skip to content

Commit

Permalink
[HOTFIX][BE]: Fix overleft missing database scheme update (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicklas373 committed May 12, 2024
2 parents 2a75e71 + 6fc408f commit 512d4f4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 49 deletions.
42 changes: 19 additions & 23 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'Method not allowed exception!',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -79,12 +79,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'Method not allowed exception!',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => null,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -101,12 +101,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'Token Mismatch exception!',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -122,7 +122,7 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => 'Route not found exception!',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
Expand All @@ -145,12 +145,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '404 - Page not found',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -166,12 +166,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '403 - Forbidden',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -187,12 +187,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '419 - Page Expired',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -208,12 +208,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '429 - Too Many Requests',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -229,14 +229,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '500 - Internal Server Error',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true,
'routeExceptionMessage' => '500 - Internal Server Error',
'routeExceptionLog' => $message
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand All @@ -252,14 +250,12 @@ public function render($request, Throwable $exception)
DB::table('appLogs')->insert([
'processId' => $uuid,
'errReason' => '503 - Service Temporary Unavailable',
'errApiReason' => $message
'errStatus' => $message
]);
DB::table('accessLogs')->insert([
'processId' => $uuid,
'routePath' => $currentRouteInfo,
'accessIpAddress' => true,
'routeExceptionMessage' => '503 - Service Temporary Unavailable',
'routeExceptionLog' => $message
'accessIpAddress' => $userIp
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $e->getMessage());
Expand Down
100 changes: 74 additions & 26 deletions app/Helpers/NotificationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ function sendErrNotify($procFile, $fileSize, $processId, $status, $proc, $errRea
]);
$messageId = $response->getMessageId();
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => null,
'errApiReason' => null,
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
Expand All @@ -85,24 +90,34 @@ function sendErrNotify($procFile, $fileSize, $processId, $status, $proc, $errRea
} else {
$httpStatus = $e->getHttpStatusCode();
}
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'TelegramResponseException',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => $e->getMessage(),
'notifyResponse' => null
'notifyMessage' => 'TelegramResponseException',
'notifyResponse' => $e->getMessage()+' | '+$httpStatus+' | '+$e->getErrorType()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
}
} catch (\Exception $e) {
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'Unexpected handling exception !',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => 'Unexpected handling exception !',
'notifyResponse' => null
'notifyResponse' => $e->getMessage()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand Down Expand Up @@ -134,6 +149,11 @@ function sendRouteErrNotify($processId, $status, $errReason, $errRoute, $errCode
$messageId = $response->getMessageId();

try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => null,
'errApiReason' => null,
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
Expand All @@ -151,24 +171,34 @@ function sendRouteErrNotify($processId, $status, $errReason, $errRoute, $errCode
} else {
$httpStatus = $e->getHttpStatusCode();
}
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'TelegramResponseException',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => $e->getMessage(),
'notifyResponse' => null
'notifyMessage' => 'TelegramResponseException',
'notifyResponse' => $e->getMessage()+' | '+$httpStatus+' | '+$e->getErrorType()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
}
} catch (\Exception $e) {
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'Unexpected handling exception !',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => 'Unexpected handling exception !',
'notifyResponse' => null
'notifyResponse' => $e->getMessage()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand Down Expand Up @@ -200,14 +230,17 @@ function sendSchedErrNotify($schedName, $schedRuntime, $processId , $status, $er
$messageId = $response->getMessageId();

try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => null,
'errApiReason' => null,
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => true,
'notifyMessage' => 'Message has been sent !',
'notifyResponse' => $response,
'notifyErrStatus' => $errReason,
'notifyErrMessage' => $errCode
'notifyResponse' => $response
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand All @@ -219,28 +252,34 @@ function sendSchedErrNotify($schedName, $schedRuntime, $processId , $status, $er
} else {
$httpStatus = $e->getHttpStatusCode();
}
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'TelegramResponseException',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => $e->getMessage(),
'notifyResponse' => null,
'notifyErrStatus' => $httpStatus,
'notifyErrMessage' => $e->getErrorType()
'notifyMessage' => 'TelegramResponseException',
'notifyResponse' => $e->getMessage()+' | '+$httpStatus+' | '+$e->getErrorType()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
}
} catch (\Exception $e) {
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'Unexpected handling exception !',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => 'Unexpected handling exception !',
'notifyResponse' => null,
'notifyErrStatus' => null,
'notifyErrMessage' => $e->getMessage()
'notifyResponse' => $e->getMessage()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand Down Expand Up @@ -288,14 +327,17 @@ function sendDailyTaskNotify($compTotalScs, $compTotalErr, $cnvTotalScs, $cnvTot
]);
$messageId = $response->getMessageId();
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => null,
'errApiReason' => null,
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => true,
'notifyMessage' => 'Message has been sent !',
'notifyResponse' => $response,
'notifyErrStatus' => $errReason,
'notifyErrMessage' => $errCode
'notifyResponse' => $response
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand All @@ -307,28 +349,34 @@ function sendDailyTaskNotify($compTotalScs, $compTotalErr, $cnvTotalScs, $cnvTot
} else {
$httpStatus = $e->getHttpStatusCode();
}
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'TelegramResponseException',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => $e->getMessage(),
'notifyResponse' => null,
'notifyErrStatus' => $httpStatus,
'notifyErrMessage' => $e->getErrorType()
'notifyMessage' => 'TelegramResponseException',
'notifyResponse' => $e->getMessage()+' | '+$httpStatus+' | '+$e->getErrorType()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
}
} catch (\Exception $e) {
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'Unexpected handling exception !',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => 'Unexpected handling exception !',
'notifyResponse' => null,
'notifyErrStatus' => null,
'notifyErrMessage' => $e->getMessage()
'notifyResponse' => $e->getMessage()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand Down

0 comments on commit 512d4f4

Please sign in to comment.