Skip to content

Commit

Permalink
add extras
Browse files Browse the repository at this point in the history
extras is a key-value map to add additional informations on a dataset
  • Loading branch information
antoine-de committed Oct 26, 2020
1 parent 2fd7d3d commit b7cd657
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions example_configuration_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ datasets:
gtfs: https://www.metromobilite.fr/data/Horaires/SEM-GTFS.zip
gtfs-rt-urls:
- https://data.metromobilite.fr/api/gtfs-rt/GAM/trip-update
extras:
datagouv_id: 5af03701b595081c1880a8a4
3 changes: 3 additions & 0 deletions src/datasets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub struct DatasetInfo {
pub id: String,
pub gtfs: String,
pub gtfs_rt_urls: Vec<String>,
#[serde(default)]
pub extras: std::collections::BTreeMap<String, String>,
}

impl DatasetInfo {
Expand All @@ -117,6 +119,7 @@ impl DatasetInfo {
name: "default name".into(),
gtfs: gtfs.to_owned(),
gtfs_rt_urls: gtfs_rt_urls.to_vec(),
extras: std::collections::BTreeMap::default(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/routes/exposed_dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct ExposedDataset {
pub name: String,
pub id: String,
pub gtfs: String,
pub extras: std::collections::BTreeMap<String, String>,
// we do not expose the gtfs-rt sources since the information can contains api key
// so we add links to the gtfs-rt routes instead
#[serde(flatten)]
Expand All @@ -19,6 +20,7 @@ impl From<&DatasetInfo> for ExposedDataset {
name: d.name.clone(),
id: d.id.clone(),
gtfs: d.gtfs.clone(),
extras: d.extras.clone(),
links: Links::default(),
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/entry_point_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ async fn test_entrypoint(srv: &mut actix_web::test::TestServer) {
},
"gtfs": "fixtures/gtfs.zip",
"id": "default",
"name": "default name"
"name": "default name",
"extras": {},
}
]
}
Expand All @@ -55,6 +56,7 @@ async fn test_dataset_entrypoint(srv: &mut actix_web::test::TestServer) {
"id": "default",
"gtfs": "fixtures/gtfs.zip",
"loaded_at": "2019-06-20T10:00:00Z",
"extras": {},
"_links": {
"general-message": {
"href": &srv.url("/default/siri/2.0/general-message.json")
Expand Down

0 comments on commit b7cd657

Please sign in to comment.