Skip to content

Commit

Permalink
front: fix unnecessary calls to simulation_summary by making postV2Tr…
Browse files Browse the repository at this point in the history
…ainScheduleProjectPath a query.

Codegen makes all the POSTs mutations by default. This one is only a POST to have a body, but is not creating/modifying anything in the DB.
No reason to be considered a mutation on the frontend.

As a query it doesn't have an invalidatesTags array anymore and prevents the unnecessary calls to simulation_summary.
  • Loading branch information
anisometropie committed Jul 17, 2024
1 parent 8035ab8 commit 089249c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ const injectedRtkApi = api
}),
invalidatesTags: ['timetablev2', 'train_schedulev2'],
}),
postV2TrainScheduleProjectPath: build.mutation<
postV2TrainScheduleProjectPath: build.query<
PostV2TrainScheduleProjectPathApiResponse,
PostV2TrainScheduleProjectPathApiArg
>({
Expand All @@ -934,7 +934,7 @@ const injectedRtkApi = api
method: 'POST',
body: queryArg.projectPathForm,
}),
invalidatesTags: ['train_schedulev2'],
providesTags: ['train_schedulev2'],
}),
postV2TrainScheduleSimulationSummary: build.query<
PostV2TrainScheduleSimulationSummaryApiResponse,
Expand Down
3 changes: 3 additions & 0 deletions front/src/common/api/osrdEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ const osrdEditoastApi = generatedEditoastApi.enhanceEndpoints({
deleteV2ProjectsByProjectIdStudiesAndStudyIdScenariosScenarioId: {
invalidatesTags: ['scenariosv2', 'studies', 'projects'],
},
postV2TrainScheduleProjectPath: {
providesTags: [],
}
},
});

Expand Down
6 changes: 5 additions & 1 deletion front/src/config/openapi-editoast-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const config: ConfigFile = {
tag: true,
endpointOverrides: [
{
pattern: ['postV2TrainSchedule', 'postV2TrainScheduleSimulationSummary'],
pattern: [
'postV2TrainSchedule',
'postV2TrainScheduleSimulationSummary',
'postV2TrainScheduleProjectPath',
],
type: 'query',
},
],
Expand Down

0 comments on commit 089249c

Please sign in to comment.