Skip to content

Commit

Permalink
Rename old fares collection tickets_v1 (#257)
Browse files Browse the repository at this point in the history
Rename old fares collection tickets_v1
  • Loading branch information
woshilapin committed Jun 3, 2019
2 parents 3cefb47 + d668c6e commit b7b9886
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/bin/read-syntus-fares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn run() -> Result<()> {
let model = transit_model::ntfs::read(opt.input)?;
let (tickets, od_rules) = syntus_fares::read(opt.fares, &model.stop_points)?;
let mut collections = model.into_collections();
collections.tickets = tickets;
collections.tickets_v1 = tickets;
collections.od_rules = od_rules;
let model = transit_model::Model::new(collections)?;
transit_model::ntfs::write(&model, opt.output, opt.current_datetime)?;
Expand Down
6 changes: 3 additions & 3 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Collections {
pub trip_properties: CollectionWithId<TripProperty>,
pub geometries: CollectionWithId<Geometry>,
#[serde(skip)]
pub tickets: Collection<TicketV1>,
pub tickets_v1: Collection<TicketV1>,
#[serde(skip)]
pub od_rules: Collection<ODRuleV1>,
pub admin_stations: Collection<AdminStation>,
Expand Down Expand Up @@ -88,15 +88,15 @@ impl Collections {
transfers,
trip_properties,
geometries,
tickets,
tickets_v1,
od_rules,
admin_stations,
stop_time_headsigns,
stop_time_ids,
stop_time_comments,
..
} = c;
self.tickets.merge(tickets);
self.tickets_v1.merge(tickets_v1);
self.od_rules.merge(od_rules);
self.contributors.try_merge(contributors)?;
self.datasets.try_merge(datasets)?;
Expand Down
4 changes: 2 additions & 2 deletions src/ntfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub fn read<P: AsRef<path::Path>>(path: P) -> Result<Model> {
read::manage_codes(&mut collections, path)?;
read::manage_comments(&mut collections, path)?;
read::manage_object_properties(&mut collections, path)?;
read::manage_fares(&mut collections, path)?;
read::manage_fares_v1(&mut collections, path)?;
info!("Indexing");
let res = Model::new(collections)?;
info!("Loading NTFS done");
Expand Down Expand Up @@ -237,7 +237,7 @@ pub fn write<P: AsRef<path::Path>>(
write::write_comments(path, model)?;
write::write_codes(path, model)?;
write::write_object_properties(path, model)?;
write::write_fares(path, &model.tickets, &model.od_rules)?;
write::write_fares_v1(path, &model.tickets_v1, &model.od_rules)?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/ntfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl From<Price> for TicketV1 {
}
}

pub fn manage_fares(collections: &mut Collections, base_path: &path::Path) -> Result<()> {
pub fn manage_fares_v1(collections: &mut Collections, base_path: &path::Path) -> Result<()> {
let file = "prices.csv";
if !base_path.join(file).exists() {
info!("Skipping fares");
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn manage_fares(collections: &mut Collections, base_path: &path::Path) -> Re
physical_mode_id: Some(physical_mode.to_string()),
});
}
collections.tickets = Collection::new(tickets);
collections.tickets_v1 = Collection::new(tickets);
collections.od_rules = Collection::new(od_rules);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/ntfs/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn write_vehicle_journeys_and_stop_times(
Ok(())
}

pub fn write_fares(
pub fn write_fares_v1(
base_path: &path::Path,
tickets: &Collection<TicketV1>,
od_rules: &Collection<ODRuleV1>,
Expand Down
8 changes: 0 additions & 8 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,6 @@ pub struct AdminStation {
}

#[derive(Debug, Clone)]
#[deprecated(
since = "0.5.0",
note = "Ticketing model in NTFS v0.9 is a breaking change, look for the Ticket struct."
)]
pub struct TicketV1 {
pub id: String,
pub start_date: NaiveDate,
Expand All @@ -1275,10 +1271,6 @@ pub struct TicketV1 {
impl_id!(TicketV1);

#[derive(Debug, Clone)]
#[deprecated(
since = "0.5.0",
note = "Ticketing model in NTFS v0.9 is a breaking change, look for the Ticket struct."
)]
pub struct ODRuleV1 {
pub id: String,
pub origin_stop_area_id: String,
Expand Down
2 changes: 1 addition & 1 deletion tests/read_syntus_fares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_read_global() {
)
.unwrap();
let mut collections = objects.into_collections();
collections.tickets = tickets;
collections.tickets_v1 = tickets;
collections.od_rules = od_rules;
let new_model = Model::new(collections).unwrap();
transit_model::ntfs::write(&new_model, path, get_test_datetime()).unwrap();
Expand Down

0 comments on commit b7b9886

Please sign in to comment.