Big of a big one, though ideally we would avoid hard coding all of the references to columns and levels through the tests to make it less effort should we need to make any changes to them moving forwards and generally reduce the maintenance burden.
@rmbielby had a neat suggestion for this:
Just thinking around a middle ground between avoiding hard-wiring and getting the readability / reliability. I'm thinking of adding a column to the dataframe called level_shorthand, which is our unchanging internal screener code for each geographic level. Then we'd have a function to pull info out:
geog_info <- function(level, param){
geographic_dataframe %>%
filter(level_shorthand == level) %>%
pull(param)
}
And then everywhere you've hardwired "region_code", you can replace that with geog_info("region", "code_field") or geog_info("la", "name_field") for "la_name" or geog_info("lad", "geographic_level") for "Local authority district".
It's short, doesn't rely on anonymous numerics and allows for us randomly needing to rename a whole geographic level in EES (which I guess is low probability, but feels like something you were trying to guard against previously).
Big of a big one, though ideally we would avoid hard coding all of the references to columns and levels through the tests to make it less effort should we need to make any changes to them moving forwards and generally reduce the maintenance burden.
@rmbielby had a neat suggestion for this:
Just thinking around a middle ground between avoiding hard-wiring and getting the readability / reliability. I'm thinking of adding a column to the dataframe called level_shorthand, which is our unchanging internal screener code for each geographic level. Then we'd have a function to pull info out:
And then everywhere you've hardwired "region_code", you can replace that with geog_info("region", "code_field") or geog_info("la", "name_field") for "la_name" or geog_info("lad", "geographic_level") for "Local authority district".
It's short, doesn't rely on anonymous numerics and allows for us randomly needing to rename a whole geographic level in EES (which I guess is low probability, but feels like something you were trying to guard against previously).