feat(dataset-groups): CRUD, latest-in-group, group SLD with dataset fallback, CreateRasterFromFile

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-05 13:29:01 +05:00
parent 32eba016b3
commit bc524f3d98
11 changed files with 1366 additions and 34 deletions

View File

@@ -32,6 +32,9 @@ api/openapi.yaml OpenAPI 3.1.1 spec (embedded + served at /openapi.yaml)
- **Category** — hierarchical (self-referencing `parent_id`). Full CRUD; cycle-safe
on update.
- **DatasetGroup** — a named group of "одноимённые" datasets (see *Dataset
groups* below). Full CRUD; deleting a group still referenced by datasets is
rejected with 409.
- **Dataset** — a geo file uploaded to S3/MinIO (`file_type`: `vector_with_kato |
vector | raster`), belonging to one Category. Carries `code`/`name`/`description`/
`unit` metadata, a user-defined `meta` (JSONB) blob, an `automated` flag, a
@@ -103,6 +106,26 @@ three are accepted on `POST /datasets` (form fields), `PUT /datasets/{id}` and
`?start_date_from=`, `?start_date_to=`, `?end_date_from=` and `?end_date_to=`
(each `YYYY-MM-DD`).
### Dataset groups
A **dataset group** (`/dataset-groups`) collects the datasets that describe the
same indicator for different periods — the "одноимённые" datasets. A group has a
slug `code` (unique), a `name` and a `description`, and datasets join it through
their `dg_id`.
**Freshness.** `GET /dataset-groups/{id}/latest` returns the group's freshest
dataset: the greatest `end_date` wins, datasets without an `end_date` come last,
and ties are broken by the newest `created_at`. Narrow the candidates with
`?status=` and `?file_type=` (for example `?status=ready&file_type=raster` to
get the latest published raster). A group with no matching dataset yields 404.
**Shared SLD.** A group can carry one SLD (Styled Layer Descriptor) style file
(`POST`/`GET /dataset-groups/{id}/sld`, multipart `file`, `.sld` or `.xml`),
which acts as the fallback style for every dataset in the group:
`GET /datasets/{id}/sld` returns the dataset's own SLD when it has one, and
otherwise falls back to its group's — 404 only when neither exists. Deleting a
group also removes its stored SLD object.
## Getting started
```sh
@@ -138,7 +161,17 @@ server runs it is served at `/openapi.yaml`, with an interactive **Redoc** UI at
| GET | `/datasets/{id}/download` | download the stored file |
| POST | `/datasets/{id}/mapping` | set KATO column + year→period map (vector_with_kato) |
| GET | `/datasets/{id}/observations` | paginated unpivoted values (`?kato_code=`, `?page=`, `?page_size=`) |
| POST | `/datasets/{id}/sld` | upload/replace the dataset's SLD (multipart `file`, `.sld`/`.xml`) |
| GET | `/datasets/{id}/sld` | download the dataset's SLD, falling back to its group's |
| DELETE | `/datasets/{id}` | delete (row + object) |
| GET | `/dataset-groups` | paginated list (`?code=`, `?page=`, `?page_size=`) |
| POST | `/dataset-groups` | create (`code`, `name`, `description?`) |
| GET | `/dataset-groups/{id}` | get |
| PUT | `/dataset-groups/{id}` | update |
| DELETE | `/dataset-groups/{id}` | delete (409 while datasets reference it) |
| GET | `/dataset-groups/{id}/latest` | freshest dataset of the group (`?status=`, `?file_type=`) |
| POST | `/dataset-groups/{id}/sld` | upload/replace the group's shared SLD |
| GET | `/dataset-groups/{id}/sld` | download the group's shared SLD |
Example upload: