Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many vehicle info responses cause crashes due to inconsistent API data structure between vehicles. #7

Open
HarvsG opened this issue Nov 26, 2017 · 3 comments

Comments

@HarvsG
Copy link
Owner

HarvsG commented Nov 26, 2017

See commented-out lines:

r-SpaceX-AI-Bot/index.js

Lines 62 to 76 in 73fbfde

// vehicle data structure is inconsistant and that breaks this https://github.com/r-spacex/SpaceX-API/issues/53
//"size": `The ${data.name} is ${data.height.meters} meters tall and ${data.diameter.meters} meters in diameter. It has a dry mass of ${data.mass.kg} kilograms. `,
"leo_weight": `The ${data.name} can launch ${data.payload_weights[0].kg} kilograms to ${data.payload_weights[0].name}`,
//engine data structure in the API differs over different vehicles. https://github.com/r-spacex/SpaceX-API/issues/53
//"gto_weight": `The ${data.name} can launch ${data.payload_weights[1].kg} kilograms to ${data.payload_weights[1].name}`,
//"mars_weight": `The ${data.name} can launch ${data.payload_weights[2].kg} kilograms to ${data.payload_weights[2].name}`,
"first_stage_reusable": `The ${data.name} is ${data.first_stage.reusable? "":"not "}a reusable rocket`,
//"engines":`The first stage has ${data.first_stage.engines.number} ${data.engines.type} ${data.engines.version}s. The second stage has ${data.second_stage.engines.number} ${data.second_stage.engines.type}s. `,
//"engine_stats":`The first stage's ${data.engines.number} ${data.first_stage.engines.type}s can burn for ${data.first_stage.burn_time_sec} with a sea level thrust of ${data.first_stage.engines.thrust_sea_level} and a vacuum thrust of ${data.first_stage.engines.thrust_vacuum}. The second stage's ${data.second_stage.engines.number} ${data.second_stage.engines.type}s can burn for ${data.second_stage.burn_time_sec} with a sea level thrust of ${data.second_stage.engines.thrust_sea_level} and a vacuum thrust of ${data.second_stage.engines.thrust_vacuum}. `,
//"fuel":`The first satge on the ${data.name} carries ${data.first_stage.fuel_amount_tons} tons of ${data.first_stage.engines.propellant_1} and ${data.first_stage.engines.propellant_2}, The second satge on the carries ${data.second_stage.fuel_amount_tons} tons of ${data.second_stage.engines.propellant_1} and ${data.second_stage.engines.propellant_2}. `,
"second_stage_payload_options":`${data.second_stage.payloads.option_1} and ${data.second_stage.payloads.option_2}`,
"fairing_size":` The fairing is ${data.second_stage.payloads.composite_fairing.height.meters} meters tall and ${data.second_stage.payloads.composite_fairing.diameter.meters} meters in diameter. `,
//"engine_loss_max":`${data.engines.engine_loss_max} can be lost during flight without causing mission failure`,
//"landing_legs":`The ${data.name} has ${data.landing_legs.number} landing legs which are made from ${data.landing_legs.material}`,
//

Related to issue r-spacex/SpaceX-API#53.

Could use various if statements to handle it, but would only be a temporary fix as it is in the pipeline to be done on the API end. Best to wait until data-structure is near-final.

@HarvsG
Copy link
Owner Author

HarvsG commented Nov 26, 2017

Dependant on r-spacex/SpaceX-API#53

@HarvsG
Copy link
Owner Author

HarvsG commented Dec 13, 2017

Issue now fixed on the API r-spacex/SpaceX-API#53

  • Needs implementing

    r-SpaceX-AI-Bot/index.js

    Lines 52 to 77 in bf2ef4a

    const VEHICLE_INFO = {
    "id": ``,
    "name": ``,
    "active": `The ${data.name} is ${data.active? "active":"not active"}. `,
    "stages": `The ${data.name} has ${data.stages} stages. `,
    "cost_per_launch": `The launch cost of the ${data.name} is ${data.cost_per_launch}. `,
    "success_rate_pct": `The success rate of the ${data.name} is ${data.success_rate_pct}%. `,
    "first_flight": `The first flight of the ${data.name} ${date}. `,
    "country": ``,
    "company": ``,
    // vehicle data structure is inconsistant and that breaks this https://github.com/r-spacex/SpaceX-API/issues/53
    //"size": `The ${data.name} is ${data.height.meters} meters tall and ${data.diameter.meters} meters in diameter. It has a dry mass of ${data.mass.kg} kilograms. `,
    "leo_weight": `The ${data.name} can launch ${data.payload_weights[0].kg} kilograms to ${data.payload_weights[0].name}. `,
    //engine data structure in the API differs over different vehicles. https://github.com/r-spacex/SpaceX-API/issues/53
    //"gto_weight": `The ${data.name} can launch ${data.payload_weights[1].kg} kilograms to ${data.payload_weights[1].name}. `,
    //"mars_weight": `The ${data.name} can launch ${data.payload_weights[2].kg} kilograms to ${data.payload_weights[2].name}. `,
    "first_stage_reusable": `The ${data.name} is ${data.first_stage.reusable? "":"not "}a reusable rocket. `,
    //"engines":`The first stage has ${data.first_stage.engines.number} ${data.engines.type} ${data.engines.version}s. The second stage has ${data.second_stage.engines.number} ${data.second_stage.engines.type}s. `,
    //"engine_stats":`The first stage's ${data.engines.number} ${data.first_stage.engines.type}s can burn for ${data.first_stage.burn_time_sec} with a sea level thrust of ${data.first_stage.engines.thrust_sea_level} and a vacuum thrust of ${data.first_stage.engines.thrust_vacuum}. The second stage's ${data.second_stage.engines.number} ${data.second_stage.engines.type}s can burn for ${data.second_stage.burn_time_sec} with a sea level thrust of ${data.second_stage.engines.thrust_sea_level} and a vacuum thrust of ${data.second_stage.engines.thrust_vacuum}. `,
    //"fuel":`The first satge on the ${data.name} carries ${data.first_stage.fuel_amount_tons} tons of ${data.first_stage.engines.propellant_1} and ${data.first_stage.engines.propellant_2}, The second satge on the carries ${data.second_stage.fuel_amount_tons} tons of ${data.second_stage.engines.propellant_1} and ${data.second_stage.engines.propellant_2}. `,
    "second_stage_payload_options":`${data.second_stage.payloads.option_1} and ${data.second_stage.payloads.option_2}. `,
    "fairing_size":` The fairing is ${data.second_stage.payloads.composite_fairing.height.meters} meters tall and ${data.second_stage.payloads.composite_fairing.diameter.meters} meters in diameter. `,
    //"engine_loss_max":`${data.engines.engine_loss_max} can be lost during flight without causing mission failure. `,
    //"landing_legs":`The ${data.name} has ${data.landing_legs.number} landing legs which are made from ${data.landing_legs.material}. `,
    //
    "description": `${data.description} `

@HarvsG
Copy link
Owner Author

HarvsG commented Feb 12, 2018

Partially solved with recent updates to the API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant