Skip to content

Commit

Permalink
editoast: remove serde default from project and study
Browse files Browse the repository at this point in the history
  • Loading branch information
Wadjetz committed Mar 20, 2024
1 parent 5408127 commit 8a4548b
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 16 deletions.
21 changes: 21 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4667,6 +4667,9 @@ components:
$ref: '#/components/schemas/Tags'
required:
- name
- description
- objectives
- funders
type: object
ProjectPatchForm:
description: Patch form for a project
Expand Down Expand Up @@ -6400,7 +6403,11 @@ components:
$ref: '#/components/schemas/Tags'
required:
- name
- description
- business_code
- service_code
- state
- study_type
type: object
StudyPatchForm:
description: This structure is used by the patch endpoint to patch a study
Expand Down Expand Up @@ -10178,6 +10185,13 @@ paths:
get:
description: Retrieve the list of conflict of the timetable (invalid trains are ignored)
parameters:
- description: The timetable id
in: path
name: id
required: true
schema:
format: int64
type: integer
- description: The infra id
in: query
name: infra_id
Expand Down Expand Up @@ -10366,6 +10380,13 @@ paths:
get:
description: Retrieve the space, speed and time curve of a given train
parameters:
- description: The timetable id
in: path
name: id
required: true
schema:
format: int64
type: integer
- description: The infra id
in: path
name: infra_id
Expand Down
10 changes: 6 additions & 4 deletions editoast/src/views/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ pub struct QueryParams {
struct ProjectCreateForm {
#[schema(max_length = 128)]
pub name: String,
#[serde(default)]
#[schema(max_length = 1024)]
pub description: String,
#[serde(default)]
#[schema(max_length = 4096)]
pub objectives: String,
#[serde(default)]
#[schema(max_length = 1024)]
pub funders: String,
pub budget: Option<i32>,
Expand Down Expand Up @@ -332,7 +329,12 @@ pub mod test {
let app = create_test_service().await;
let req = TestRequest::post()
.uri("/projects")
.set_json(json!({ "name": "test_project","description": "", "objectives":"" }))
.set_json(json!({
"name": "test_project",
"description": "",
"objectives": "",
"funders": "",
}))
.to_request();
let response = call_service(&app, req).await;
assert_eq!(response.status(), StatusCode::OK);
Expand Down
13 changes: 8 additions & 5 deletions editoast/src/views/study.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,16 @@ pub enum StudyError {
#[derivative(Default)]
struct StudyCreateForm {
pub name: String,
#[serde(default)]
pub description: String,
pub start_date: Option<NaiveDate>,
pub expected_end_date: Option<NaiveDate>,
pub actual_end_date: Option<NaiveDate>,
#[serde(default)]
pub business_code: String,
#[serde(default)]
pub service_code: String,
pub budget: Option<i32>,
#[serde(default)]
pub tags: Tags,
pub state: String,
#[serde(default)]
pub study_type: String,
}

Expand Down Expand Up @@ -434,7 +430,14 @@ pub mod test {
let project = project.await;
let req = TestRequest::post()
.uri(format!("/projects/{}/studies/", project.id()).as_str())
.set_json(json!({ "name": "study_test", "state": "Starting" }))
.set_json(json!({
"name": "study_test",
"description": "Study description",
"state": "Starting",
"business_code": "",
"service_code": "",
"study_type": "",
}))
.to_request();
let response = call_service(&app, req).await;
assert_eq!(response.status(), StatusCode::OK);
Expand Down
1 change: 1 addition & 0 deletions editoast/src/views/v2/timetable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ pub struct Conflict {
#[utoipa::path(
tag = "timetablev2",
params(
("id" = i64, Path, description = "The timetable id"),
("infra_id" = i64, Query, description = "The infra id"),
),
responses(
Expand Down
1 change: 1 addition & 0 deletions editoast/src/views/v2/train_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ pub struct MrspPoint {
#[utoipa::path(
tag = "train_schedulev2",
params(
("id" = i64, Path, description = "The timetable id"),
("infra_id" = i64, Path, description = "The infra id"),
),
responses(
Expand Down
112 changes: 105 additions & 7 deletions front/src/common/api/osrdEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,16 @@ const injectedRtkApi = api
}),
invalidatesTags: ['timetablev2'],
}),
getV2TimetableByIdConflicts: build.query<
GetV2TimetableByIdConflictsApiResponse,
GetV2TimetableByIdConflictsApiArg
>({
query: (queryArg) => ({
url: `/v2/timetable/${queryArg.id}/conflicts/`,
params: { infra_id: queryArg.infraId },
}),
providesTags: ['timetablev2'],
}),
deleteV2TrainSchedule: build.mutation<
DeleteV2TrainScheduleApiResponse,
DeleteV2TrainScheduleApiArg
Expand All @@ -855,6 +865,20 @@ const injectedRtkApi = api
query: (queryArg) => ({ url: `/v2/train_schedule/`, method: 'POST', body: queryArg.body }),
invalidatesTags: ['train_schedulev2'],
}),
postV2TrainScheduleProjectPath: build.mutation<
PostV2TrainScheduleProjectPathApiResponse,
PostV2TrainScheduleProjectPathApiArg
>({
query: (queryArg) => ({ url: `/v2/train_schedule/project_path/`, method: 'POST' }),
invalidatesTags: ['train_schedulev2'],
}),
getV2TrainScheduleSimulationSummary: build.query<
GetV2TrainScheduleSimulationSummaryApiResponse,
GetV2TrainScheduleSimulationSummaryApiArg
>({
query: (queryArg) => ({ url: `/v2/train_schedule/simulation_summary/` }),
providesTags: ['train_schedulev2'],
}),
getV2TrainScheduleById: build.query<
GetV2TrainScheduleByIdApiResponse,
GetV2TrainScheduleByIdApiArg
Expand All @@ -873,6 +897,13 @@ const injectedRtkApi = api
}),
invalidatesTags: ['train_schedulev2', 'timetable'],
}),
getV2TrainScheduleByIdSimulation: build.query<
GetV2TrainScheduleByIdSimulationApiResponse,
GetV2TrainScheduleByIdSimulationApiArg
>({
query: (queryArg) => ({ url: `/v2/train_schedule/${queryArg.id}/simulation/` }),
providesTags: ['train_schedulev2'],
}),
getVersion: build.query<GetVersionApiResponse, GetVersionApiArg>({
query: () => ({ url: `/version/` }),
}),
Expand Down Expand Up @@ -1586,6 +1617,14 @@ export type PutV2TimetableByIdApiArg = {
id: number;
timetableForm: TimetableForm;
};
export type GetV2TimetableByIdConflictsApiResponse =
/** status 200 list of conflict */ ConflictV2[];
export type GetV2TimetableByIdConflictsApiArg = {
/** The timetable id */
id: number;
/** The infra id */
infraId: number;
};
export type DeleteV2TrainScheduleApiResponse = unknown;
export type DeleteV2TrainScheduleApiArg = {
body: {
Expand All @@ -1597,6 +1636,22 @@ export type PostV2TrainScheduleApiResponse =
export type PostV2TrainScheduleApiArg = {
body: TrainScheduleForm[];
};
export type PostV2TrainScheduleProjectPathApiResponse = /** status 200 Project Path Output */ {
[key: string]: ProjectPathResult;
};
export type PostV2TrainScheduleProjectPathApiArg = {
infra: number;
trainIds: number[];
};
export type GetV2TrainScheduleSimulationSummaryApiResponse = /** status 200 Project Path Output */ {
[key: string]: SimulationSummaryResultResponse;
};
export type GetV2TrainScheduleSimulationSummaryApiArg = {
infra: number;
trainIds: number[];
/** The infra id */
infraId: number;
};
export type GetV2TrainScheduleByIdApiResponse =
/** status 200 The train schedule */ TrainScheduleResult;
export type GetV2TrainScheduleByIdApiArg = {
Expand All @@ -1610,6 +1665,14 @@ export type PutV2TrainScheduleByIdApiArg = {
id: number;
trainScheduleForm: TrainScheduleForm;
};
export type GetV2TrainScheduleByIdSimulationApiResponse =
/** status 200 Simulation Output */ SimulationOutput;
export type GetV2TrainScheduleByIdSimulationApiArg = {
/** The timetable id */
id: number;
/** The infra id */
infraId: number;
};
export type GetVersionApiResponse = /** status 200 Return the service version */ Version;
export type GetVersionApiArg = void;
export type GetVersionCoreApiResponse = /** status 200 Return the core service version */ Version;
Expand Down Expand Up @@ -2059,12 +2122,12 @@ export type Ordering =
| 'LastModifiedAsc';
export type ProjectCreateForm = {
budget?: number | null;
description?: string;
funders?: string;
description: string;
funders: string;
/** The id of the image document */
image?: number | null;
name: string;
objectives?: string;
objectives: string;
tags?: Tags;
};
export type ProjectPatchForm = {
Expand Down Expand Up @@ -2114,14 +2177,14 @@ export type StudyResponse = Study & {
export type StudyCreateForm = {
actual_end_date?: string | null;
budget?: number | null;
business_code?: string;
description?: string;
business_code: string;
description: string;
expected_end_date?: string | null;
name: string;
service_code?: string;
service_code: string;
start_date?: string | null;
state: string;
study_type?: string;
study_type: string;
tags?: Tags;
};
export type StudyPatchForm = {
Expand Down Expand Up @@ -2994,6 +3057,13 @@ export type TimetableDetailedResult = {
} & {
train_ids: number[];
};
export type ConflictV2 = {
conflict_type: ConflictType;
end_time: string;
start_time: string;
train_ids: number[];
train_names: string[];
};
export type Distribution = 'STANDARD' | 'MARECO';
export type TrainScheduleBase = {
comfort: 'STANDARD' | 'AIR_CONDITIONING' | 'HEATING';
Expand Down Expand Up @@ -3055,6 +3125,34 @@ export type TrainScheduleResult = TrainScheduleBase & {
export type TrainScheduleForm = TrainScheduleBase & {
timetable_id: number;
};
export type ProjectPathResult = {
blocks: SignalUpdate[];
positions: number[];
times: number[];
};
export type SimulationSummaryResultResponse =
| {
Success: {
energy_consumption: number;
length: number;
time: number;
};
}
| 'PathfindingNotFound'
| 'RunningTimeNotFound';
export type CompleteReportTrain = ReportTrain & {
routing_requirements: RoutingRequirement[];
signal_sightings: SignalSighting[];
spacing_requirements: SpacingRequirement[];
zone_updates: ZoneUpdate[];
};
export type SimulationOutput = {
base: ReportTrain;
final_output: CompleteReportTrain;
mrsp: Mrsp;
power_restriction: string;
provisional: ReportTrain;
};
export type Version = {
git_describe: string | null;
};

0 comments on commit 8a4548b

Please sign in to comment.