feat: fix seeder

This commit is contained in:
Leon 2026-01-14 16:22:23 +01:00
parent 83f92dd7a1
commit d47058054d
2 changed files with 50 additions and 49 deletions

View File

@ -23,8 +23,9 @@ class LevelSeeder extends Seeder
$levelsPerTier = 10; $levelsPerTier = 10;
$baseXp = 50; $baseXp = 50;
$scalingFactor = 20; $scalingFactor = 20;
$totalLevels = count($tiers) * $levelsPerTier;
for ($level = 1; $level <= 100; $level++) { for ($level = 1; $level <= $totalLevels; $level++) {
// Déterminer le tier // Déterminer le tier
$tierIndex = intdiv($level - 1, $levelsPerTier); $tierIndex = intdiv($level - 1, $levelsPerTier);

View File

@ -23,56 +23,56 @@ services:
DB_USERNAME: "${DB_USERNAME}" DB_USERNAME: "${DB_USERNAME}"
DB_PASSWORD: "${DB_PASSWORD}" DB_PASSWORD: "${DB_PASSWORD}"
treasure-api-migrate: # treasure-api-migrate:
image: registry.gitlab.com/treasure-hunt4/treasure-api:latest # image: registry.gitlab.com/treasure-hunt4/treasure-api:latest
restart: "no" # restart: "no"
depends_on: # depends_on:
- mysql # - mysql
environment: # environment:
APP_ENV: "production" # APP_ENV: "production"
APP_KEY: "${APP_KEY}" # APP_KEY: "${APP_KEY}"
APP_URL: "${APP_URL}" # APP_URL: "${APP_URL}"
SCOUT_DRIVER: "${SCOUT_DRIVER}" # SCOUT_DRIVER: "${SCOUT_DRIVER}"
MEILISEARCH_HOST: "${MEILISEARCH_HOST}" # MEILISEARCH_HOST: "${MEILISEARCH_HOST}"
MEILISEARCH_KEY: "${MEILISEARCH_KEY}" # MEILISEARCH_KEY: "${MEILISEARCH_KEY}"
DB_CONNECTION: "mysql" # DB_CONNECTION: "mysql"
DB_HOST: "mysql" # DB_HOST: "mysql"
DB_PORT: 3306 # DB_PORT: 3306
DB_DATABASE: "${DB_DATABASE}" # DB_DATABASE: "${DB_DATABASE}"
DB_USERNAME: "${DB_USERNAME}" # DB_USERNAME: "${DB_USERNAME}"
DB_PASSWORD: "${DB_PASSWORD}" # DB_PASSWORD: "${DB_PASSWORD}"
# On attend que MySQL soit prêt et on retente la migration jusqu'à succès # # On attend que MySQL soit prêt et on retente la migration jusqu'à succès
command: > # command: >
sh -c " # sh -c "
echo '⏳ Waiting for MySQL on mysql:3306...'; # echo '⏳ Waiting for MySQL on mysql:3306...';
php -r ' # php -r '
$host = getenv(\"DB_HOST\") ?: \"mysql\"; # $host = getenv(\"DB_HOST\") ?: \"mysql\";
$port = getenv(\"DB_PORT\") ?: \"3306\"; # $port = getenv(\"DB_PORT\") ?: \"3306\";
$db = getenv(\"DB_DATABASE\") ?: \"\"; # $db = getenv(\"DB_DATABASE\") ?: \"\";
$user = getenv(\"DB_USERNAME\") ?: \"\"; # $user = getenv(\"DB_USERNAME\") ?: \"\";
$pass = getenv(\"DB_PASSWORD\") ?: \"\"; # $pass = getenv(\"DB_PASSWORD\") ?: \"\";
while (true) { # while (true) {
try { # try {
new PDO(\"mysql:host={$host};port={$port};dbname={$db}\", $user, $pass); # new PDO(\"mysql:host={$host};port={$port};dbname={$db}\", $user, $pass);
break; # break;
} catch (Throwable $e) { # } catch (Throwable $e) {
echo \"MySQL not ready: {$e->getMessage()}\\n\"; # echo \"MySQL not ready: {$e->getMessage()}\\n\";
sleep(2); # sleep(2);
} # }
} # }
'; # ';
echo '✅ MySQL is up, running migrations...'; # echo '✅ MySQL is up, running migrations...';
until php artisan migrate --force --no-interaction; do # until php artisan migrate --force --no-interaction; do
echo '❌ Migration failed, retrying in 5s...'; # echo '❌ Migration failed, retrying in 5s...';
sleep 5; # sleep 5;
done; # done;
echo '✅ Migrations applied.'; # echo '✅ Migrations applied.';
echo '🔗 Creating storage symlink...'; # echo '🔗 Creating storage symlink...';
php artisan storage:link || true; # php artisan storage:link || true;
echo '✅ Storage link done.'; # echo '✅ Storage link done.';
" # "
phpmyadmin: phpmyadmin:
image: phpmyadmin:latest image: phpmyadmin:latest