Skip to content

Commit bd7f8de

Browse files
committed
add data path to dataset update and fix camel case in getting dataset data path
1 parent ee58c8c commit bd7f8de

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

services/src/api/handlers/datasets.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,11 @@ pub async fn update_dataset_handler<C: ApplicationContext>(
670670
})
671671
.context(CannotLoadDatasetForUpdate)?;
672672

673+
// TODO: if the data_path is changed, validate that
674+
// - it exists
675+
// - it is accessible
676+
// - all files referenced by the dataset still exist?
677+
673678
session_ctx
674679
.update_dataset(dataset_id, update.into_inner())
675680
.await
@@ -1807,7 +1812,10 @@ mod tests {
18071812
},
18081813
raster::{GridShape2D, TilingSpecification},
18091814
spatial_reference::SpatialReferenceOption,
1810-
util::{assert_image_equals, test::assert_eq_two_list_of_tiles},
1815+
util::{
1816+
assert_image_equals,
1817+
test::{TestDefault, assert_eq_two_list_of_tiles},
1818+
},
18111819
};
18121820
use geoengine_operators::{
18131821
engine::{
@@ -3250,6 +3258,7 @@ mod tests {
32503258
display_name: "new display name".to_string(),
32513259
description: "new description".to_string(),
32523260
tags: vec!["foo".to_string(), "bar".to_string()],
3261+
data_path: Some(DataPath::test_default()),
32533262
};
32543263

32553264
let req = actix_web::test::TestRequest::post()
@@ -3268,6 +3277,7 @@ mod tests {
32683277
assert_eq!(dataset.display_name, update.display_name);
32693278
assert_eq!(dataset.description, update.description);
32703279
assert_eq!(dataset.tags, Some(update.tags));
3280+
assert_eq!(dataset.data_path, update.data_path);
32713281

32723282
Ok(())
32733283
}

services/src/api/model/services.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub struct CreateDataset {
156156
pub definition: DatasetDefinition,
157157
}
158158

159-
#[derive(Deserialize, Serialize, Debug, Clone, ToSchema)]
159+
#[derive(Deserialize, Serialize, Debug, Clone, ToSchema, PartialEq, Eq)]
160160
#[serde(rename_all = "camelCase")]
161161
pub enum DataPath {
162162
Volume(VolumeName),
@@ -170,14 +170,15 @@ impl TestDefault for DataPath {
170170
}
171171

172172
#[derive(Deserialize, Serialize, Debug, Clone, ToSchema, Validate)]
173+
#[serde(rename_all = "camelCase")]
173174
pub struct UpdateDataset {
174175
pub name: DatasetName,
175176
#[validate(length(min = 1))]
176177
pub display_name: String,
177178
pub description: String,
178179
#[validate(custom(function = "validate_tags"))]
179180
pub tags: Vec<String>,
180-
// TODO: result descriptor update? or change the model so that the result descriptor is only part of the metadata
181+
pub data_path: Option<DataPath>, // TODO: make mandatory
181182
}
182183

183184
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone, ToSchema, Validate)]

services/src/datasets/postgres.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,13 +1171,14 @@ where
11711171
.boxed_context(crate::error::PermissionDb)?;
11721172

11731173
tx.execute(
1174-
"UPDATE datasets SET name = $2, display_name = $3, description = $4, tags = $5 WHERE id = $1;",
1174+
"UPDATE datasets SET name = $2, display_name = $3, description = $4, tags = $5, data_path = $6 WHERE id = $1;",
11751175
&[
11761176
&dataset,
11771177
&update.name,
11781178
&update.display_name,
11791179
&update.description,
11801180
&update.tags,
1181+
&update.data_path,
11811182
],
11821183
)
11831184
.await?;

0 commit comments

Comments
 (0)