Skip to content

Commit ee58c8c

Browse files
committed
clean up code
1 parent 4a75152 commit ee58c8c

File tree

3 files changed

+267
-12
lines changed

3 files changed

+267
-12
lines changed

openapi.json

Lines changed: 254 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,72 @@
806806
}
807807
},
808808
"/dataset/{dataset}/tiles": {
809+
"get": {
810+
"tags": [
811+
"Datasets"
812+
],
813+
"summary": "Retrieves details about a dataset using the internal name.",
814+
"operationId": "get_dataset_tiles_handler",
815+
"parameters": [
816+
{
817+
"name": "dataset",
818+
"in": "path",
819+
"description": "Dataset Name",
820+
"required": true,
821+
"schema": {
822+
"$ref": "#/components/schemas/DatasetName"
823+
}
824+
},
825+
{
826+
"name": "offset",
827+
"in": "query",
828+
"required": true,
829+
"schema": {
830+
"type": "integer",
831+
"format": "int32",
832+
"minimum": 0
833+
}
834+
},
835+
{
836+
"name": "limit",
837+
"in": "query",
838+
"required": true,
839+
"schema": {
840+
"type": "integer",
841+
"format": "int32",
842+
"minimum": 0
843+
}
844+
}
845+
],
846+
"responses": {
847+
"200": {
848+
"description": "OK",
849+
"content": {
850+
"application/json": {
851+
"schema": {
852+
"type": "array",
853+
"items": {
854+
"$ref": "#/components/schemas/DatasetTile"
855+
}
856+
}
857+
}
858+
}
859+
},
860+
"401": {
861+
"$ref": "#/components/responses/UnauthorizedUserResponse"
862+
}
863+
},
864+
"security": [
865+
{
866+
"session_token": []
867+
}
868+
]
869+
},
809870
"post": {
810871
"tags": [
811872
"Datasets"
812873
],
813-
"summary": "Add a tile to a gdal dataset.",
874+
"summary": "Add tiles to a gdal dataset.",
814875
"operationId": "add_dataset_tiles_handler",
815876
"parameters": [
816877
{
@@ -827,15 +888,121 @@
827888
"content": {
828889
"application/json": {
829890
"schema": {
830-
"$ref": "#/components/schemas/AutoCreateDataset"
891+
"type": "array",
892+
"items": {
893+
"$ref": "#/components/schemas/AddDatasetTile"
894+
}
831895
}
832896
}
833897
},
834898
"required": true
835899
},
836900
"responses": {
837901
"200": {
838-
"description": ""
902+
"description": "OK",
903+
"content": {
904+
"application/json": {
905+
"schema": {
906+
"type": "array",
907+
"items": {
908+
"$ref": "#/components/schemas/DatasetTileId"
909+
}
910+
}
911+
}
912+
}
913+
}
914+
},
915+
"security": [
916+
{
917+
"session_token": []
918+
}
919+
]
920+
},
921+
"delete": {
922+
"tags": [
923+
"Datasets"
924+
],
925+
"summary": "Retrieves details about a dataset using the internal name.",
926+
"operationId": "delete_dataset_tiles_handler",
927+
"parameters": [
928+
{
929+
"name": "dataset",
930+
"in": "path",
931+
"description": "Dataset Name",
932+
"required": true,
933+
"schema": {
934+
"$ref": "#/components/schemas/DatasetName"
935+
}
936+
}
937+
],
938+
"requestBody": {
939+
"content": {
940+
"application/json": {
941+
"schema": {
942+
"$ref": "#/components/schemas/DeleteDatasetTiles"
943+
}
944+
}
945+
},
946+
"required": true
947+
},
948+
"responses": {
949+
"200": {
950+
"description": "OK"
951+
},
952+
"401": {
953+
"$ref": "#/components/responses/UnauthorizedUserResponse"
954+
}
955+
},
956+
"security": [
957+
{
958+
"session_token": []
959+
}
960+
]
961+
}
962+
},
963+
"/dataset/{dataset}/tiles/{tile}": {
964+
"put": {
965+
"tags": [
966+
"Datasets"
967+
],
968+
"summary": "Retrieves details about a dataset using the internal name.",
969+
"operationId": "update_dataset_tile_handler",
970+
"parameters": [
971+
{
972+
"name": "dataset",
973+
"in": "path",
974+
"description": "Dataset Name",
975+
"required": true,
976+
"schema": {
977+
"$ref": "#/components/schemas/DatasetName"
978+
}
979+
},
980+
{
981+
"name": "tile",
982+
"in": "path",
983+
"description": "Tile Id",
984+
"required": true,
985+
"schema": {
986+
"$ref": "#/components/schemas/DatasetTileId"
987+
}
988+
}
989+
],
990+
"requestBody": {
991+
"content": {
992+
"application/json": {
993+
"schema": {
994+
"$ref": "#/components/schemas/UpdateDatasetTile"
995+
}
996+
}
997+
},
998+
"required": true
999+
},
1000+
"responses": {
1001+
"200": {
1002+
"description": "OK"
1003+
},
1004+
"401": {
1005+
"$ref": "#/components/responses/UnauthorizedUserResponse"
8391006
}
8401007
},
8411008
"security": [
@@ -6240,12 +6407,65 @@
62406407
}
62416408
}
62426409
},
6410+
"DatasetTile": {
6411+
"type": "object",
6412+
"required": [
6413+
"id",
6414+
"time",
6415+
"spatial_partition",
6416+
"band",
6417+
"z_index",
6418+
"params"
6419+
],
6420+
"properties": {
6421+
"band": {
6422+
"type": "integer",
6423+
"format": "int32",
6424+
"minimum": 0
6425+
},
6426+
"id": {
6427+
"$ref": "#/components/schemas/DatasetTileId"
6428+
},
6429+
"params": {
6430+
"$ref": "#/components/schemas/GdalDatasetParameters"
6431+
},
6432+
"spatial_partition": {
6433+
"$ref": "#/components/schemas/SpatialPartition2D"
6434+
},
6435+
"time": {
6436+
"$ref": "#/components/schemas/TimeInterval"
6437+
},
6438+
"z_index": {
6439+
"type": "integer",
6440+
"format": "int32",
6441+
"minimum": 0
6442+
}
6443+
}
6444+
},
6445+
"DatasetTileId": {
6446+
"type": "string",
6447+
"format": "uuid"
6448+
},
62436449
"DateTimeParseFormat": {
62446450
"type": "string"
62456451
},
62466452
"DateTimeString": {
62476453
"type": "string"
62486454
},
6455+
"DeleteDatasetTiles": {
6456+
"type": "object",
6457+
"required": [
6458+
"tileIds"
6459+
],
6460+
"properties": {
6461+
"tileIds": {
6462+
"type": "array",
6463+
"items": {
6464+
"$ref": "#/components/schemas/DatasetTileId"
6465+
}
6466+
}
6467+
}
6468+
},
62496469
"DerivedColor": {
62506470
"type": "object",
62516471
"required": [
@@ -10287,6 +10507,37 @@
1028710507
}
1028810508
}
1028910509
},
10510+
"UpdateDatasetTile": {
10511+
"type": "object",
10512+
"required": [
10513+
"time",
10514+
"spatial_partition",
10515+
"band",
10516+
"z_index",
10517+
"params"
10518+
],
10519+
"properties": {
10520+
"band": {
10521+
"type": "integer",
10522+
"format": "int32",
10523+
"minimum": 0
10524+
},
10525+
"params": {
10526+
"$ref": "#/components/schemas/GdalDatasetParameters"
10527+
},
10528+
"spatial_partition": {
10529+
"$ref": "#/components/schemas/SpatialPartition2D"
10530+
},
10531+
"time": {
10532+
"$ref": "#/components/schemas/TimeInterval"
10533+
},
10534+
"z_index": {
10535+
"type": "integer",
10536+
"format": "int32",
10537+
"minimum": 0
10538+
}
10539+
}
10540+
},
1029010541
"UpdateLayer": {
1029110542
"type": "object",
1029210543
"required": [

services/src/api/handlers/datasets.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,12 @@ pub async fn delete_dataset_tiles_handler<C: ApplicationContext>(
556556
})
557557
.context(CannotLoadDatasetForGettingTiles)?;
558558

559-
let tiles = session_ctx
559+
session_ctx
560560
.delete_dataset_tiles(dataset_id, delete.into_inner().tile_ids)
561561
.await
562562
.context(CannotLoadDatasetTiles)?;
563563

564-
Ok(web::Json(tiles))
564+
Ok(HttpResponse::Ok())
565565
}
566566

567567
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, ToSchema)]
@@ -5670,17 +5670,17 @@ mod tests {
56705670
returned_tiles[0],
56715671
DatasetTile {
56725672
id: returned_tiles[0].id,
5673-
time: tiles[0].time.clone(),
5674-
spatial_partition: tiles[0].spatial_partition.clone(),
5673+
time: tiles[0].time,
5674+
spatial_partition: tiles[0].spatial_partition,
56755675
band: tiles[0].band,
56765676
z_index: tiles[0].z_index,
56775677
params: tiles[0].params.clone()
56785678
}
56795679
);
56805680

56815681
let update_tile = UpdateDatasetTile {
5682-
time: tiles[0].time.clone(),
5683-
spatial_partition: tiles[0].spatial_partition.clone(),
5682+
time: tiles[0].time,
5683+
spatial_partition: tiles[0].spatial_partition,
56845684
band: tiles[0].band,
56855685
z_index: tiles[0].z_index + 1,
56865686
params: tiles[0].params.clone(),
@@ -5711,8 +5711,8 @@ mod tests {
57115711
returned_tiles[0],
57125712
DatasetTile {
57135713
id: returned_tiles[0].id,
5714-
time: tiles[0].time.clone(),
5715-
spatial_partition: tiles[0].spatial_partition.clone(),
5714+
time: tiles[0].time,
5715+
spatial_partition: tiles[0].spatial_partition,
57165716
band: tiles[0].band,
57175717
z_index: tiles[0].z_index + 1,
57185718
params: tiles[0].params.clone()

services/src/datasets/postgres.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,11 @@ where
13531353
z_index
13541354
OFFSET $2
13551355
LIMIT $3",
1356-
&[&dataset, &(params.offset as i64), &(params.limit as i64)],
1356+
&[
1357+
&dataset,
1358+
&i64::from(params.offset),
1359+
&i64::from(params.limit),
1360+
],
13571361
)
13581362
.await?;
13591363

0 commit comments

Comments
 (0)