Skip to content

Commit 9baa18a

Browse files
fixes flight summary retrieval
1 parent e9b2345 commit 9baa18a

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

src/controllers/environment.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ async def get_rocketpy_environment_binary(
3636
Raises:
3737
HTTP 404 Not Found: If the env is not found in the database.
3838
"""
39-
env_retrieved = await self.get_environment_by_id(env_id)
40-
env_service = EnvironmentService.from_env_model(
41-
env_retrieved.environment
42-
)
39+
env = await self.get_environment_by_id(env_id)
40+
env_service = EnvironmentService.from_env_model(env.environment)
4341
return env_service.get_environment_binary()
4442

4543
@controller_exception_handler
@@ -58,8 +56,6 @@ async def get_environment_simulation(
5856
Raises:
5957
HTTP 404 Not Found: If the env does not exist in the database.
6058
"""
61-
env_retrieved = await self.get_environment_by_id(env_id)
62-
env_service = EnvironmentService.from_env_model(
63-
env_retrieved.environment
64-
)
59+
env = await self.get_environment_by_id(env_id)
60+
env_service = EnvironmentService.from_env_model(env.environment)
6561
return env_service.get_environment_simulation()

src/controllers/flight.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,8 @@ async def get_rocketpy_flight_binary(
8282
Raises:
8383
HTTP 404 Not Found: If the flight is not found in the database.
8484
"""
85-
flight_retrieved = await self.get_flight_by_id(flight_id)
86-
flight_service = FlightService.from_flight_model(
87-
flight_retrieved.flight
88-
)
85+
flight = await self.get_flight_by_id(flight_id)
86+
flight_service = FlightService.from_flight_model(flight.flight)
8987
return flight_service.get_flight_binary()
9088

9189
@controller_exception_handler
@@ -105,8 +103,6 @@ async def get_flight_simulation(
105103
Raises:
106104
HTTP 404 Not Found: If the flight does not exist in the database.
107105
"""
108-
flight_retrieved = await self.get_flight_by_id(flight_id=flight_id)
109-
flight_service = FlightService.from_flight_model(
110-
flight_retrieved.flight
111-
)
106+
flight = await self.get_flight_by_id(flight_id)
107+
flight_service = FlightService.from_flight_model(flight.flight)
112108
return flight_service.get_flight_simulation()

src/controllers/motor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ async def get_rocketpy_motor_binary(
3636
Raises:
3737
HTTP 404 Not Found: If the motor is not found in the database.
3838
"""
39-
motor_retrieved = await self.get_motor_by_id(motor_id)
40-
motor_service = MotorService.from_motor_model(motor_retrieved.motor)
39+
motor = await self.get_motor_by_id(motor_id)
40+
motor_service = MotorService.from_motor_model(motor.motor)
4141
return motor_service.get_motor_binary()
4242

4343
@controller_exception_handler
@@ -54,6 +54,6 @@ async def get_motor_simulation(self, motor_id: str) -> MotorSimulation:
5454
Raises:
5555
HTTP 404 Not Found: If the motor does not exist in the database.
5656
"""
57-
motor_retrieved = await self.get_motor_by_id(motor_id)
58-
motor_service = MotorService.from_motor_model(motor_retrieved.motor)
57+
motor = await self.get_motor_by_id(motor_id)
58+
motor_service = MotorService.from_motor_model(motor.motor)
5959
return motor_service.get_motor_simulation()

src/controllers/rocket.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ async def get_rocketpy_rocket_binary(self, rocket_id: str) -> bytes:
3333
Raises:
3434
HTTP 404 Not Found: If the rocket is not found in the database.
3535
"""
36-
rocket_retrieved = await self.get_rocket_by_id(rocket_id)
37-
rocket_service = RocketService.from_rocket_model(
38-
rocket_retrieved.rocket
39-
)
36+
rocket = await self.get_rocket_by_id(rocket_id)
37+
rocket_service = RocketService.from_rocket_model(rocket.rocket)
4038
return rocket_service.get_rocket_binary()
4139

4240
@controller_exception_handler
@@ -56,8 +54,6 @@ async def get_rocket_simulation(
5654
Raises:
5755
HTTP 404 Not Found: If the rocket does not exist in the database.
5856
"""
59-
rocket_retrieved = await self.get_rocket_by_id(rocket_id)
60-
rocket_service = RocketService.from_rocket_model(
61-
rocket_retrieved.rocket
62-
)
57+
rocket = await self.get_rocket_by_id(rocket_id)
58+
rocket_service = RocketService.from_rocket_model(rocket.rocket)
6359
return rocket_service.get_rocket_simulation()

0 commit comments

Comments
 (0)