Skip to content

Commit 6d33ff6

Browse files
committed
editoast: move Study to ModelV2
1 parent 55b1ff3 commit 6d33ff6

File tree

10 files changed

+299
-389
lines changed

10 files changed

+299
-389
lines changed

editoast/openapi.yaml

+4-10
Original file line numberDiff line numberDiff line change
@@ -5421,7 +5421,6 @@ components:
54215421
- distribution
54225422
type: object
54235423
Study:
5424-
additionalProperties: false
54255424
properties:
54265425
actual_end_date:
54275426
format: date
@@ -5463,9 +5462,7 @@ components:
54635462
study_type:
54645463
type: string
54655464
tags:
5466-
items:
5467-
type: string
5468-
type: array
5465+
$ref: '#/components/schemas/Tags'
54695466
required:
54705467
- id
54715468
- name
@@ -5511,9 +5508,7 @@ components:
55115508
study_type:
55125509
type: string
55135510
tags:
5514-
items:
5515-
type: string
5516-
type: array
5511+
$ref: '#/components/schemas/Tags'
55175512
required:
55185513
- name
55195514
- state
@@ -5556,10 +5551,9 @@ components:
55565551
nullable: true
55575552
type: string
55585553
tags:
5559-
items:
5560-
type: string
5554+
allOf:
5555+
- $ref: '#/components/schemas/Tags'
55615556
nullable: true
5562-
type: array
55635557
type: object
55645558
StudyResponse:
55655559
allOf:

editoast/src/fixtures.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ pub mod tests {
77
use crate::models::{
88
self, ElectricalProfileSet, Identifiable, Infra, Pathfinding, PathfindingChangeset,
99
ResultPosition, ResultStops, ResultTrain, RollingStockLiveryModel, RollingStockModel,
10-
Scenario, SimulationOutput, SimulationOutputChangeset, Study, Timetable, TrainSchedule,
10+
Scenario, SimulationOutput, SimulationOutputChangeset, Timetable, TrainSchedule,
1111
};
1212
use crate::modelsv2::projects::Tags;
1313
use crate::modelsv2::timetable::Timetable as TimetableV2;
1414
use crate::modelsv2::train_schedule::TrainSchedule as TrainScheduleV2;
15-
use crate::modelsv2::{self, Document, Model, Project};
15+
use crate::modelsv2::{self, Document, Model, Project, Study};
1616
use crate::schema::electrical_profiles::{ElectricalProfile, ElectricalProfileSetData};
1717
use crate::schema::v2::trainschedule::TrainScheduleBase;
1818
use crate::schema::{RailJson, TrackRange};
@@ -283,22 +283,22 @@ pub mod tests {
283283
#[future] project: TestFixture<Project>,
284284
) -> StudyFixtureSet {
285285
let project = project.await;
286-
let study_model = Study {
287-
name: Some("test_study".into()),
288-
project_id: Some(project.id()),
289-
description: Some("test".into()),
290-
creation_date: Some(Utc::now().naive_utc()),
291-
business_code: Some("AAA".into()),
292-
service_code: Some("BBB".into()),
293-
state: Some("some_type".into()),
294-
study_type: Some("some_type".into()),
295-
budget: Some(0),
296-
tags: Some(vec![]),
297-
..Default::default()
298-
};
286+
let study_model = Study::changeset()
287+
.name("test_study".into())
288+
.description("test".into())
289+
.creation_date(Utc::now().naive_utc())
290+
.business_code("AAA".into())
291+
.service_code("BBB".into())
292+
.creation_date(Utc::now().naive_utc())
293+
.last_modification(Utc::now().naive_utc())
294+
.budget(0)
295+
.tags(Tags::default())
296+
.state("some_state".into())
297+
.study_type("some_type".into())
298+
.project_id(project.id());
299299
StudyFixtureSet {
300300
project,
301-
study: TestFixture::create_legacy(study_model, db_pool).await,
301+
study: TestFixture::create(study_model, db_pool).await,
302302
}
303303
}
304304

editoast/src/models/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub mod infra;
33
pub mod pathfinding;
44
pub mod rolling_stock;
55
mod scenario;
6-
mod study;
76
mod text_array;
87
mod timetable;
98
pub mod train_schedule;
@@ -20,7 +19,6 @@ pub use electrical_profiles::ElectricalProfileSet;
2019
pub use infra::Infra;
2120
pub use rolling_stock::{LightRollingStockModel, RollingStockLiveryModel, RollingStockModel};
2221
pub use scenario::{Scenario, ScenarioWithCountTrains, ScenarioWithDetails};
23-
pub use study::{Study, StudyWithScenarios};
2422
pub use text_array::TextArray;
2523
pub use timetable::{check_train_validity, Timetable, TimetableWithSchedulesDetails};
2624
pub use train_schedule::{

editoast/src/models/study.rs

-254
This file was deleted.

editoast/src/modelsv2/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ pub mod documents;
22
pub mod infra_objects;
33
pub mod projects;
44
pub mod railjson;
5+
pub mod study;
56
pub mod timetable;
67
pub mod train_schedule;
78

89
pub use documents::Document;
910
pub use infra_objects::*;
10-
pub use projects::{Ordering, Project};
11+
pub use projects::{Ordering, Project, Tags};
12+
pub use study::Study;
1113

1214
use async_trait::async_trait;
1315
use diesel::{pg::Pg, result::Error::NotFound, AsChangeset, QueryableByName};

0 commit comments

Comments
 (0)