geobeyond / Arpav-PPCV-backend

Backend di Piattaforma Proiezioni Climatiche per il Nord-Est.
Creative Commons Attribution 4.0 International
0 stars 1 forks source link

Use a coverage configuration's possible values as a way to describe it #168

Closed ricardogsilva closed 1 month ago

ricardogsilva commented 2 months ago

This PR refactors the way coverage configurations and identifiers are generated in order to make it easier for the frontend to discover them.

It makes it possible for the frontend to discover coverage identifiers by using the possible_value query parameter. All possible values used by a coverage configuration are thus searchable. As an example a request like this:

GET /api/v2/coverages/coverage-identifiers \
    possible_value==climatological_model:model_ensemble \
    possible_value==scenario:rcp26 \
    possible_value==measure:absolute

Will now make the backend search through all defined coverage configurations and return the respective coverage identifiers that can be generated from the coverage configurations which satisfy the conditions given by ANDing the various possible_value query params.

This would be the response:

{
    "items": [
        {
            "identifier": "tas_seasonal_absolute_model_ensemble-model_ensemble-absolute-rcp26-DJF",
            "related_coverage_configuration_url": "http://localhost:8877/api/v2/coverages/coverage-configurations/06c104d2-a502-400b-9728-b8e2d9ee65d9",
            "wms_base_url": "http://thredds:8080/thredds/wms/ensymbc/clipped/tas_avg_rcp26_DJF_ts19762100_ls_VFVG.nc",
            "wms_main_layer_name": "tas"
        },
        {
            "identifier": "tas_seasonal_absolute_model_ensemble-model_ensemble-absolute-rcp26-MAM",
            "related_coverage_configuration_url": "http://localhost:8877/api/v2/coverages/coverage-configurations/06c104d2-a502-400b-9728-b8e2d9ee65d9",
            "wms_base_url": "http://thredds:8080/thredds/wms/ensymbc/clipped/tas_avg_rcp26_MAM_ts19762100_ls_VFVG.nc",
            "wms_main_layer_name": "tas"
        },
        {
            "identifier": "tas_seasonal_absolute_model_ensemble-model_ensemble-absolute-rcp26-JJA",
            "related_coverage_configuration_url": "http://localhost:8877/api/v2/coverages/coverage-configurations/06c104d2-a502-400b-9728-b8e2d9ee65d9",
            "wms_base_url": "http://thredds:8080/thredds/wms/ensymbc/clipped/tas_avg_rcp26_JJA_ts19762100_ls_VFVG.nc",
            "wms_main_layer_name": "tas"
        },
        {
            "identifier": "tas_seasonal_absolute_model_ensemble-model_ensemble-absolute-rcp26-SON",
            "related_coverage_configuration_url": "http://localhost:8877/api/v2/coverages/coverage-configurations/06c104d2-a502-400b-9728-b8e2d9ee65d9",
            "wms_base_url": "http://thredds:8080/thredds/wms/ensymbc/clipped/tas_avg_rcp26_SON_ts19762100_ls_VFVG.nc",
            "wms_main_layer_name": "tas"
        }
    ],
    "links": {
        "first": "http://localhost:8877/api/v2/coverages/coverage-identifiers?limit=20&offset=0&possible_value=measure:absolute",
        "last": "http://localhost:8877/api/v2/coverages/coverage-identifiers?limit=20&offset=0&possible_value=measure:absolute",
        "next": null,
        "previous": null,
        "self": "http://localhost:8877/api/v2/coverages/coverage-identifiers?limit=20&offset=0&possible_value=measure:absolute"
    },
    "meta": {
        "returned_records": 4,
        "total_filtered_records": 4,
        "total_records": 1785
    }

The practical aspect of this PR is that the frontend does not need to know the coverage identifiers in advance (they become irrelevant) and only needs to ensure that it knows about the relevant ConfigurationParameter's that it needs to use.

This PR does not yet update the bootstrap fixtures with all of this new metadata. This will be done in the next PR.

Also included is a fix for the admin section, whereby it is now possible to filter list pages.