Restore platform route and db diagnostics

This commit is contained in:
2026-05-21 13:22:17 -05:00
parent c477643781
commit 94064b27c3
4 changed files with 68 additions and 1 deletions

View File

@@ -53,6 +53,19 @@ class GameController extends Controller
return response()->json($games);
}
/**
* Ranking por plataforma
*/
public function platformRanking($platform)
{
$games = Game::where('platform', $platform)
->orderBy('weekly_points', 'desc')
->take(10)
->get();
return response()->json($games);
}
/**
* Histórico de ranking
*

View File

@@ -15,7 +15,11 @@ return [
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
'default' => env('DB_CONNECTION') ?: (
str_starts_with((string) env('DATABASE_URL'), 'postgres')
? 'pgsql'
: 'mysql'
),
/*
|--------------------------------------------------------------------------

View File

@@ -1,6 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use App\Http\Controllers\GameController;
/*
@@ -16,6 +18,7 @@ Route::prefix('v1')->middleware(['jwt.auth'])->group(function () {
Route::get('/rankings/monthly', [GameController::class, 'monthlyRanking']);
Route::get('/rankings/yearly', [GameController::class, 'yearlyRanking']);
Route::get('/rankings/history/{id}', [GameController::class, 'history']);
Route::get('/rankings/platforms/{platform}', [GameController::class, 'platformRanking']);
// Jogos
Route::get('/games/most-played', [GameController::class, 'mostPlayed']);
@@ -37,3 +40,22 @@ Route::get('/health-check-key', function () {
'openssl_error' => openssl_error_string(),
]);
});
Route::get('/health-check-db', function () {
try {
$hasGamesTable = Schema::hasTable('games');
return response()->json([
'connection' => config('database.default'),
'driver' => DB::connection()->getDriverName(),
'database' => DB::connection()->getDatabaseName(),
'games_table_exists' => $hasGamesTable,
'games_count' => $hasGamesTable ? DB::table('games')->count() : null,
]);
} catch (Throwable $e) {
return response()->json([
'connection' => config('database.default'),
'error' => $e->getMessage(),
], 500);
}
});

View File

@@ -1,6 +1,15 @@
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
Route::get('/', function () {
return response()->json([
'status' => 'ok',
'service' => 'api-ranking-jogos',
]);
});
Route::get('/health', function () {
return response()->json(['status' => 'ok']);
@@ -18,3 +27,22 @@ Route::get('/health-check-key', function () {
'openssl_error' => openssl_error_string(),
]);
});
Route::get('/health-check-db', function () {
try {
$hasGamesTable = Schema::hasTable('games');
return response()->json([
'connection' => config('database.default'),
'driver' => DB::connection()->getDriverName(),
'database' => DB::connection()->getDatabaseName(),
'games_table_exists' => $hasGamesTable,
'games_count' => $hasGamesTable ? DB::table('games')->count() : null,
]);
} catch (Throwable $e) {
return response()->json([
'connection' => config('database.default'),
'error' => $e->getMessage(),
], 500);
}
});