@@ -217,7 +217,7 @@ struct BatchRequest {
217
217
async fn get_batch (
218
218
app_state : State < AppState > ,
219
219
Extension ( authorizer) : AuthorizerExt ,
220
- Json ( data ) : Json < BatchRequest > ,
220
+ Json ( BatchRequest { ids : train_ids } ) : Json < BatchRequest > ,
221
221
) -> Result < Json < Vec < TrainScheduleResult > > > {
222
222
let authorized = authorizer
223
223
. check_roles ( [ BuiltinRole :: InfraRead , BuiltinRole :: TimetableRead ] . into ( ) )
@@ -229,7 +229,6 @@ async fn get_batch(
229
229
230
230
let db_pool = app_state. db_pool_v2 . clone ( ) ;
231
231
let conn = & mut db_pool. get ( ) . await ?;
232
- let train_ids = data. ids ;
233
232
let train_schedules: Vec < TrainSchedule > =
234
233
TrainSchedule :: retrieve_batch_or_fail ( conn, train_ids, |missing| {
235
234
TrainScheduleError :: BatchTrainScheduleNotFound {
@@ -252,7 +251,7 @@ async fn get_batch(
252
251
async fn delete (
253
252
app_state : State < AppState > ,
254
253
Extension ( authorizer) : AuthorizerExt ,
255
- Json ( data ) : Json < BatchRequest > ,
254
+ Json ( BatchRequest { ids : train_ids } ) : Json < BatchRequest > ,
256
255
) -> Result < impl IntoResponse > {
257
256
let authorized = authorizer
258
257
. check_roles ( [ BuiltinRole :: InfraRead , BuiltinRole :: TimetableWrite ] . into ( ) )
@@ -266,8 +265,7 @@ async fn delete(
266
265
267
266
use crate :: modelsv2:: DeleteBatch ;
268
267
let conn = & mut db_pool. get ( ) . await ?;
269
- let train_schedule_ids = data. ids ;
270
- TrainSchedule :: delete_batch_or_fail ( conn, train_schedule_ids, |number| {
268
+ TrainSchedule :: delete_batch_or_fail ( conn, train_ids, |number| {
271
269
TrainScheduleError :: BatchTrainScheduleNotFound { number }
272
270
} )
273
271
. await ?;
@@ -289,7 +287,7 @@ async fn put(
289
287
db_pool : State < DbConnectionPoolV2 > ,
290
288
Extension ( authorizer) : AuthorizerExt ,
291
289
train_schedule_id : Path < TrainScheduleIdParam > ,
292
- Json ( data ) : Json < TrainScheduleForm > ,
290
+ Json ( train_schedule_form ) : Json < TrainScheduleForm > ,
293
291
) -> Result < Json < TrainScheduleResult > > {
294
292
let authorized = authorizer
295
293
. check_roles ( [ BuiltinRole :: InfraRead , BuiltinRole :: TimetableWrite ] . into ( ) )
@@ -302,7 +300,7 @@ async fn put(
302
300
let conn = & mut db_pool. get ( ) . await ?;
303
301
304
302
let train_schedule_id = train_schedule_id. id ;
305
- let ts_changeset: TrainScheduleChangeset = data . into ( ) ;
303
+ let ts_changeset: TrainScheduleChangeset = train_schedule_form . into ( ) ;
306
304
307
305
let ts_result = ts_changeset
308
306
. update_or_fail ( conn, train_schedule_id, || TrainScheduleError :: NotFound {
@@ -672,7 +670,11 @@ enum SimulationSummaryResult {
672
670
async fn simulation_summary (
673
671
app_state : State < AppState > ,
674
672
Extension ( authorizer) : AuthorizerExt ,
675
- Json ( data) : Json < SimulationBatchForm > ,
673
+ Json ( SimulationBatchForm {
674
+ infra_id,
675
+ electrical_profile_set_id,
676
+ ids : train_schedule_ids,
677
+ } ) : Json < SimulationBatchForm > ,
676
678
) -> Result < Json < HashMap < i64 , SimulationSummaryResult > > > {
677
679
let authorized = authorizer
678
680
. check_roles ( [ BuiltinRole :: InfraRead , BuiltinRole :: TimetableRead ] . into ( ) )
@@ -686,12 +688,6 @@ async fn simulation_summary(
686
688
let redis_client = app_state. redis . clone ( ) ;
687
689
let core = app_state. core_client . clone ( ) ;
688
690
689
- let SimulationBatchForm {
690
- infra_id,
691
- electrical_profile_set_id,
692
- ids : train_schedule_ids,
693
- } = data;
694
-
695
691
let infra = Infra :: retrieve_or_fail ( db_pool. get ( ) . await ?. deref_mut ( ) , infra_id, || {
696
692
TrainScheduleError :: InfraNotFound { infra_id }
697
693
} )
0 commit comments