Skip to content

Commit

Permalink
editoast: move Study to ModelV2
Browse files Browse the repository at this point in the history
  • Loading branch information
hamz2a committed Feb 28, 2024
1 parent 55b1ff3 commit 6d33ff6
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 389 deletions.
14 changes: 4 additions & 10 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5421,7 +5421,6 @@ components:
- distribution
type: object
Study:
additionalProperties: false
properties:
actual_end_date:
format: date
Expand Down Expand Up @@ -5463,9 +5462,7 @@ components:
study_type:
type: string
tags:
items:
type: string
type: array
$ref: '#/components/schemas/Tags'
required:
- id
- name
Expand Down Expand Up @@ -5511,9 +5508,7 @@ components:
study_type:
type: string
tags:
items:
type: string
type: array
$ref: '#/components/schemas/Tags'
required:
- name
- state
Expand Down Expand Up @@ -5556,10 +5551,9 @@ components:
nullable: true
type: string
tags:
items:
type: string
allOf:
- $ref: '#/components/schemas/Tags'
nullable: true
type: array
type: object
StudyResponse:
allOf:
Expand Down
32 changes: 16 additions & 16 deletions editoast/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pub mod tests {
use crate::models::{
self, ElectricalProfileSet, Identifiable, Infra, Pathfinding, PathfindingChangeset,
ResultPosition, ResultStops, ResultTrain, RollingStockLiveryModel, RollingStockModel,
Scenario, SimulationOutput, SimulationOutputChangeset, Study, Timetable, TrainSchedule,
Scenario, SimulationOutput, SimulationOutputChangeset, Timetable, TrainSchedule,
};
use crate::modelsv2::projects::Tags;
use crate::modelsv2::timetable::Timetable as TimetableV2;
use crate::modelsv2::train_schedule::TrainSchedule as TrainScheduleV2;
use crate::modelsv2::{self, Document, Model, Project};
use crate::modelsv2::{self, Document, Model, Project, Study};
use crate::schema::electrical_profiles::{ElectricalProfile, ElectricalProfileSetData};
use crate::schema::v2::trainschedule::TrainScheduleBase;
use crate::schema::{RailJson, TrackRange};
Expand Down Expand Up @@ -283,22 +283,22 @@ pub mod tests {
#[future] project: TestFixture<Project>,
) -> StudyFixtureSet {
let project = project.await;
let study_model = Study {
name: Some("test_study".into()),
project_id: Some(project.id()),
description: Some("test".into()),
creation_date: Some(Utc::now().naive_utc()),
business_code: Some("AAA".into()),
service_code: Some("BBB".into()),
state: Some("some_type".into()),
study_type: Some("some_type".into()),
budget: Some(0),
tags: Some(vec![]),
..Default::default()
};
let study_model = Study::changeset()
.name("test_study".into())
.description("test".into())
.creation_date(Utc::now().naive_utc())
.business_code("AAA".into())
.service_code("BBB".into())
.creation_date(Utc::now().naive_utc())
.last_modification(Utc::now().naive_utc())
.budget(0)
.tags(Tags::default())
.state("some_state".into())
.study_type("some_type".into())
.project_id(project.id());
StudyFixtureSet {
project,
study: TestFixture::create_legacy(study_model, db_pool).await,
study: TestFixture::create(study_model, db_pool).await,
}
}

Expand Down
2 changes: 0 additions & 2 deletions editoast/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub mod infra;
pub mod pathfinding;
pub mod rolling_stock;
mod scenario;
mod study;
mod text_array;
mod timetable;
pub mod train_schedule;
Expand All @@ -20,7 +19,6 @@ pub use electrical_profiles::ElectricalProfileSet;
pub use infra::Infra;
pub use rolling_stock::{LightRollingStockModel, RollingStockLiveryModel, RollingStockModel};
pub use scenario::{Scenario, ScenarioWithCountTrains, ScenarioWithDetails};
pub use study::{Study, StudyWithScenarios};
pub use text_array::TextArray;
pub use timetable::{check_train_validity, Timetable, TimetableWithSchedulesDetails};
pub use train_schedule::{
Expand Down
254 changes: 0 additions & 254 deletions editoast/src/models/study.rs

This file was deleted.

4 changes: 3 additions & 1 deletion editoast/src/modelsv2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ pub mod documents;
pub mod infra_objects;
pub mod projects;
pub mod railjson;
pub mod study;
pub mod timetable;
pub mod train_schedule;

pub use documents::Document;
pub use infra_objects::*;
pub use projects::{Ordering, Project};
pub use projects::{Ordering, Project, Tags};
pub use study::Study;

use async_trait::async_trait;
use diesel::{pg::Pg, result::Error::NotFound, AsChangeset, QueryableByName};
Expand Down
Loading

0 comments on commit 6d33ff6

Please sign in to comment.