Skip to content

Commit

Permalink
Merge pull request #516 from mrc-ide/comparison-metadata
Browse files Browse the repository at this point in the history
Comparison metadata
  • Loading branch information
r-ash authored May 20, 2024
2 parents a472994 + 9792203 commit a392713
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Docker Image

on:
push:
branches: [main, master, tmp-epic-plot-cleanup-input, new-calibrate-metadata]
branches: [main, master, tmp-epic-plot-cleanup-input, comparison-metadata]
pull_request:
branches: [main, master, tmp-epic-plot-cleanup-input, new-calibrate-metadata]
branches: [main, master, tmp-epic-plot-cleanup-input, comparison-metadata]

jobs:
docker:
Expand Down
5 changes: 3 additions & 2 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,11 @@ calibrate_metadata <- function(queue) {
if (!is.null(result$warnings)) {
warnings <- warnings_scalar(result$warnings)
}
filter_types <- get_model_output_filters(output)
list(
filterTypes = get_model_output_filters(output),
filterTypes = filter_types,
indicators = get_indicator_metadata("output", "choropleth", output),
plotSettingsControl = get_output_plot_settings_control(),
plotSettingsControl = get_output_plot_settings_control(filter_types),
warnings = warnings
)
}
Expand Down
40 changes: 32 additions & 8 deletions R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ get_country_iso3 <- function(area_ids) {
sub("([A-Z]{3}).*", "\\1", area_ids[1])
}

get_output_plot_settings_control <- function() {
get_output_plot_settings_control <- function(filter_types) {
list(
choropleth = get_choropleth_settings(),
barchart = get_barchart_settings(),
table = get_table_settings(),
table = get_table_settings(filter_types),
bubble = get_bubble_settings()
)
}
Expand Down Expand Up @@ -249,27 +249,47 @@ get_x_axis_or_disagg_by_option <- function(id) {
)
}

get_table_settings <- function() {
get_table_settings <- function(filter_types) {
list(
defaultEffect = list(
setFilterValues = list(
indicator = c("prevalence"),
period = get_filter_option_ids(filter_types, "period")[2]
)
),
plotSettings = list(
list(
id = scalar("presets"),
label = scalar(t_("OUTPUT_TABLE_PRESETS")),
options = get_table_presets()
options = get_table_presets(filter_types)
)
)
)
}

get_table_presets <- function() {
get_table_presets <- function(filter_types) {
detail_options <- get_filter_option_ids(filter_types, "detail")
list(
list(
id = scalar("sex_by_area"),
label = scalar(t_("TABLE_SEX_BY_AREA")),
effect = list(
setFilters = lapply(c("indicator", "detail", "period", "sex", "age"),
get_filter_from_id),
setMultiple = c("sex")
setFilters = lapply(
c("indicator", "area", "detail", "period", "sex", "age"),
get_filter_from_id),
## Hide the area ID as we want people to just select the detail level
## and see all rows within that level. Having the area filter available
## too makes this confusing, but we need area to exist for picking
## up the row labels
setHidden = c("area"),
setMultiple = c("sex", "area"),
setFilterValues = list(
detail = detail_options[length(detail_options)]
),
customPlotEffect = list(
row = c("area"),
column = c("sex")
)
)
),
list(
Expand All @@ -281,6 +301,10 @@ get_table_presets <- function() {
setMultiple = c("sex", "age"),
setFilterValues = list(
age = naomi::get_five_year_age_groups()
),
customPlotEffect = list(
row = c("age"),
column = c("sex")
)
)
)
Expand Down
28 changes: 28 additions & 0 deletions inst/schema/CustomPlotMetadata.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"tableMetadata": {
"type": "object",
"properties": {
"row": {
"type": "array",
"items": {
"type": "string"
}
},
"column": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [ "row", "column" ]
}
},
"type": "object",
"oneOf": [
{ "$ref": "#/definitions/tableMetadata" }
]
}
3 changes: 2 additions & 1 deletion inst/schema/PlotSettingEffect.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"items": {
"type": "string"
}
}
},
"customPlotEffect": { "$ref": "CustomPlotMetadata.schema.json" }
},
"additionalProperties": false
}
62 changes: 0 additions & 62 deletions inst/schema/TableMetadata.schema.json

This file was deleted.

0 comments on commit a392713

Please sign in to comment.