40245-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-06-11 07:53:44 +00:00

2019 lines
37 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Cars = db.cars;
const RaceTypes = db.race_types;
const UpgradeRules = db.upgrade_rules;
const TuningRecipes = db.tuning_recipes;
const CarsData = [
{
"brand": "Acura",
"model": "NSX Type S",
"year": 2022,
"rarity": "Legendary",
"origin": "PlaylistReward",
"origin_detail": "Blue Wristband Unlock",
"country": "United States",
"initial_class": "S1",
"initial_pi": 734,
"speed_rating": 7.3,
"handling_rating": 6.2,
"acceleration_rating": 8.7,
"braking_rating": 7.7,
"offroad_rating": 6.9,
"power_hp": 608,
"torque_kgfm": 68.0,
"weight_kg": 1770,
"front_weight_percent": 43,
"displacement_liters": 3.5,
"stock_drivetrain": "AWD",
// type code here for "images" field
},
{
"brand": "Alfa Romeo",
"model": "Giulia Quadrifoglio",
"year": 2017,
"rarity": "Epic",
"origin": "PlaylistReward",
"origin_detail": "Autoshow and Wheelspin",
"country": "Italy",
"initial_class": "D",
"initial_pi": 667,
"speed_rating": 7.3,
"handling_rating": 6.4,
"acceleration_rating": 5.9,
"braking_rating": 4.9,
"offroad_rating": 6.7,
"power_hp": 510,
"torque_kgfm": 61.0,
"weight_kg": 1580,
"front_weight_percent": 50,
"displacement_liters": 2.9,
"stock_drivetrain": "AWD",
// type code here for "images" field
},
{
"brand": "Autozam",
"model": "AZ-1",
"year": 1993,
"rarity": "Epic",
"origin": "SpecialUnlock",
"origin_detail": "Autoshow and Wheelspin",
"country": "Japan",
"initial_class": "C",
"initial_pi": 342,
"speed_rating": 4.2,
"handling_rating": 4.2,
"acceleration_rating": 3.0,
"braking_rating": 4.4,
"offroad_rating": 3.0,
"power_hp": 64,
"torque_kgfm": 8.7,
"weight_kg": 720,
"front_weight_percent": 44,
"displacement_liters": 0.7,
"stock_drivetrain": "FWD",
// type code here for "images" field
},
{
"brand": "Nissan",
"model": "GT-R",
"year": 2020,
"rarity": "ForzaEdition",
"origin": "Autoshow",
"origin_detail": "Autoshow",
"country": "Japan",
"initial_class": "B",
"initial_pi": 760,
"speed_rating": 7.8,
"handling_rating": 6.0,
"acceleration_rating": 7.6,
"braking_rating": 6.2,
"offroad_rating": 5.5,
"power_hp": 565,
"torque_kgfm": 65.0,
"weight_kg": 1740,
"front_weight_percent": 54,
"displacement_liters": 3.8,
"stock_drivetrain": "AWD",
// type code here for "images" field
},
];
const RaceTypesData = [
{
"category_name": "Corridas de Rua",
"terrain_type": "Dirt",
"description": "Races on public roads with traffic elements and mixed corner types.",
"driving_focus": "Grip",
},
{
"category_name": "Corridas de Estrada",
"terrain_type": "Asphalt",
"description": "Closed-road events emphasizing consistent pace, braking points, and corner exits.",
"driving_focus": "Grip",
},
{
"category_name": "Corridas na Terra",
"terrain_type": "Dirt",
"description": "Dirt events requiring traction management, suspension compliance, and stable torque delivery.",
"driving_focus": "TopSpeed",
},
{
"category_name": "Cross-Country",
"terrain_type": "Asphalt",
"description": "Off-road routes with jumps and uneven terrain; demands durability and AWD traction.",
"driving_focus": "Off-road",
},
];
const UpgradeRulesData = [
{
// type code here for "relation_one" field
"target_class": "C",
"recommended_drivetrain": "FWD",
"engine_priority": "Intake and exhaust upgrades for responsive power, upgrade cooling if available, keep power balanced with grip.",
"chassis_priority": "Race suspension, weight reduction stages, race brakes, anti-roll bars for stability.",
"tires_aero_priority": "Sport or semi-slick tires, wider rear tires where possible, adjustable aero for high-speed stability.",
"min_offroad_rating_for_offroad": 6.0,
"front_weight_alert_threshold": 55,
"fine_tuning_tip_template": "If front weight is high, soften front rebound and increase rear anti-roll bar to reduce understeer.",
},
{
// type code here for "relation_one" field
"target_class": "B",
"recommended_drivetrain": "KeepStock",
"engine_priority": "Maximize turbo and intercooler upgrades, prioritize transmission and differential for acceleration and stability.",
"chassis_priority": "Full weight reduction, race brakes, race suspension tuned for bumpy roads.",
"tires_aero_priority": "Semi-slick tires, adjustable rear wing for stability, keep front aero moderate to reduce drag.",
"min_offroad_rating_for_offroad": 6.0,
"front_weight_alert_threshold": 55,
"fine_tuning_tip_template": "Use slightly longer final drive for top-speed segments and reduce rear downforce if traction is stable.",
},
{
// type code here for "relation_one" field
"target_class": "X",
"recommended_drivetrain": "KeepStock",
"engine_priority": "Max engine upgrades including turbo, intercooler, camshaft, fuel system, and ignition; prioritize launch power.",
"chassis_priority": "Reduce weight where it does not hurt traction, drag suspension if available, upgrade drivetrain components.",
"tires_aero_priority": "Drag compound tires, remove wings to reduce drag, optimize tire width for launch.",
"min_offroad_rating_for_offroad": 6.0,
"front_weight_alert_threshold": 55,
"fine_tuning_tip_template": "Lower rear tire pressure and shorten first and second gears to improve launch consistency.",
},
{
// type code here for "relation_one" field
"target_class": "R",
"recommended_drivetrain": "FWD",
"engine_priority": "Increase torque-focused upgrades and avoid peaky power; prioritize flywheel and driveline response.",
"chassis_priority": "Rally suspension, reinforcement if available, keep ride height suitable for ruts and bumps.",
"tires_aero_priority": "Dirt tires, moderate aero, prioritize tire width over downforce.",
"min_offroad_rating_for_offroad": 6.0,
"front_weight_alert_threshold": 55,
"fine_tuning_tip_template": "If off-road rating is low, raise ride height and soften damping to maintain contact over bumps.",
},
];
const TuningRecipesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_class": "D",
"recommended_drivetrain": "RWD",
"drivetrain_checklist": "Keep stock AWD, add race differential, upgrade clutch and driveline for faster shifts.",
"engine_checklist": "Upgrade intake and exhaust, add better cooling, mild turbo upgrade if PI allows, upgrade transmission.",
"chassis_tires_checklist": "Race suspension, weight reduction stage 2, race brakes, anti-roll bars tuned for neutral balance.",
"aero_checklist": "Install adjustable rear wing, moderate downforce for stability in fast corners.",
"alerts": "No critical alerts. Off-road suitability is acceptable but not relevant for asphalt.",
"fine_tuning_tip": "Increase rear anti-roll bar slightly if understeer appears on corner entry.",
"recipe_status": "archived",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_class": "D",
"recommended_drivetrain": "KeepStock",
"drivetrain_checklist": "Convert to AWD for launch stability, install race differential, upgrade transmission for acceleration.",
"engine_checklist": "Turbo and intercooler upgrades, fuel system and ignition upgrades, optimize gearing for mixed straights.",
"chassis_tires_checklist": "Race suspension, weight reduction stage 2, race brakes, wider rear tires.",
"aero_checklist": "Add adjustable rear wing for high-speed stability, keep front aero minimal to reduce drag.",
"alerts": "Braking rating is low; prioritize race brakes and tire compound early.",
"fine_tuning_tip": "Set brake bias slightly forward for stability, then adjust rear anti-roll bar to reduce mid-corner push.",
"recipe_status": "draft",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_class": "D",
"recommended_drivetrain": "KeepStock",
"drivetrain_checklist": "Keep RWD, install drag tires, upgrade differential and transmission, optimize final drive for launch.",
"engine_checklist": "Max intake, exhaust, turbo upgrade if available, camshaft and fuel system, keep power within PI target.",
"chassis_tires_checklist": "Weight reduction stage 2, drag suspension if available, rear tire width upgrade.",
"aero_checklist": "Remove rear wing to reduce drag, avoid unnecessary aero parts.",
"alerts": "Low acceleration baseline; expect major gains only with engine swaps or forced induction where available.",
"fine_tuning_tip": "Shorten first gear and reduce rear tire pressure to improve launch traction.",
"recipe_status": "generated",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"target_class": "R",
"recommended_drivetrain": "AWD",
"drivetrain_checklist": "Convert to AWD, upgrade differential for loose surface traction, reinforce driveline.",
"engine_checklist": "Focus on torque upgrades, avoid excessive top-end tuning, upgrade cooling if needed.",
"chassis_tires_checklist": "Rally suspension, dirt tires, increase ride height, weight reduction stage 1 for stability.",
"aero_checklist": "Minimal aero, prioritize tire width and suspension travel.",
"alerts": "Off-road rating below 6.0; severe adaptation recommended including rally suspension, dirt tires, and AWD.",
"fine_tuning_tip": "Soften damping and raise ride height to maintain grip in ruts; reduce rear anti-roll bar if oversteer on exit.",
"recipe_status": "archived",
},
];
// Similar logic for "relation_many"
async function associateUpgradeRuleWithTarget_race_type() {
const relatedTarget_race_type0 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const UpgradeRule0 = await UpgradeRules.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UpgradeRule0?.setTarget_race_type)
{
await
UpgradeRule0.
setTarget_race_type(relatedTarget_race_type0);
}
const relatedTarget_race_type1 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const UpgradeRule1 = await UpgradeRules.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UpgradeRule1?.setTarget_race_type)
{
await
UpgradeRule1.
setTarget_race_type(relatedTarget_race_type1);
}
const relatedTarget_race_type2 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const UpgradeRule2 = await UpgradeRules.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UpgradeRule2?.setTarget_race_type)
{
await
UpgradeRule2.
setTarget_race_type(relatedTarget_race_type2);
}
const relatedTarget_race_type3 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const UpgradeRule3 = await UpgradeRules.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UpgradeRule3?.setTarget_race_type)
{
await
UpgradeRule3.
setTarget_race_type(relatedTarget_race_type3);
}
}
async function associateTuningRecipeWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const TuningRecipe0 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TuningRecipe0?.setUser)
{
await
TuningRecipe0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const TuningRecipe1 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TuningRecipe1?.setUser)
{
await
TuningRecipe1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const TuningRecipe2 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TuningRecipe2?.setUser)
{
await
TuningRecipe2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const TuningRecipe3 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TuningRecipe3?.setUser)
{
await
TuningRecipe3.
setUser(relatedUser3);
}
}
async function associateTuningRecipeWithCar() {
const relatedCar0 = await Cars.findOne({
offset: Math.floor(Math.random() * (await Cars.count())),
});
const TuningRecipe0 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TuningRecipe0?.setCar)
{
await
TuningRecipe0.
setCar(relatedCar0);
}
const relatedCar1 = await Cars.findOne({
offset: Math.floor(Math.random() * (await Cars.count())),
});
const TuningRecipe1 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TuningRecipe1?.setCar)
{
await
TuningRecipe1.
setCar(relatedCar1);
}
const relatedCar2 = await Cars.findOne({
offset: Math.floor(Math.random() * (await Cars.count())),
});
const TuningRecipe2 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TuningRecipe2?.setCar)
{
await
TuningRecipe2.
setCar(relatedCar2);
}
const relatedCar3 = await Cars.findOne({
offset: Math.floor(Math.random() * (await Cars.count())),
});
const TuningRecipe3 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TuningRecipe3?.setCar)
{
await
TuningRecipe3.
setCar(relatedCar3);
}
}
async function associateTuningRecipeWithRace_type() {
const relatedRace_type0 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const TuningRecipe0 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (TuningRecipe0?.setRace_type)
{
await
TuningRecipe0.
setRace_type(relatedRace_type0);
}
const relatedRace_type1 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const TuningRecipe1 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (TuningRecipe1?.setRace_type)
{
await
TuningRecipe1.
setRace_type(relatedRace_type1);
}
const relatedRace_type2 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const TuningRecipe2 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (TuningRecipe2?.setRace_type)
{
await
TuningRecipe2.
setRace_type(relatedRace_type2);
}
const relatedRace_type3 = await RaceTypes.findOne({
offset: Math.floor(Math.random() * (await RaceTypes.count())),
});
const TuningRecipe3 = await TuningRecipes.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (TuningRecipe3?.setRace_type)
{
await
TuningRecipe3.
setRace_type(relatedRace_type3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Cars.bulkCreate(CarsData);
await RaceTypes.bulkCreate(RaceTypesData);
await UpgradeRules.bulkCreate(UpgradeRulesData);
await TuningRecipes.bulkCreate(TuningRecipesData);
await Promise.all([
// Similar logic for "relation_many"
await associateUpgradeRuleWithTarget_race_type(),
await associateTuningRecipeWithUser(),
await associateTuningRecipeWithCar(),
await associateTuningRecipeWithRace_type(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('cars', null, {});
await queryInterface.bulkDelete('race_types', null, {});
await queryInterface.bulkDelete('upgrade_rules', null, {});
await queryInterface.bulkDelete('tuning_recipes', null, {});
},
};