I’m going to try to build a library (that I can hopefully publish) that allows access to statistics reports from the Swedish Statistics Authority. Basically they have a bunch of statistics data but the issue is they use very weird API:s for accessing them so I wanna provide a more easy way to get the data by wrapping the api:s in a nice library.
However they have a lot of reports and data so I will probably have to write a module per report. And it seems a bit wasteful to include all (I’m not sure how many reports in total they got but wouldn’t be surprised if it is over 500) for a project that just wanna access how the population size of each municipality.
I get that it might be hard/impossible to “tree-shake” since code can be called dynamically at runtime but can I provide a way to for example specify in the config which reports they want to actually use? Something like this:
config :scb_ex,
reports: [:municipality_population]
I guess you could hack it by slightly changing your approach.
Instead of a single mix project, you can have a single umbrella project and your modules will become small libraries.
You can control what has access to what with Boundary — boundary v0.10.3 to provide a meaningful error when one “module/report” depends on another that is not compiled (strongly advised against it).
Or you can extract these common pieces to the Core
which is exposed to all Report
s.
1 Like
There was just a post on the Dashbit blog arguing for smaller SDK surfaces:
Are the many reports different enough to need different code?
6 Likes
Yea, at least if I wanna wrap it in a nicer way than it is now. I will see if I end up doing that or just providing a slightly improved API. Each report got its own url and then you query it with json. But the filter options are different on each report so the very least I would need to provide different query schemas for each report.
{
"query": [
{
"code": "Region",
"selection": {
"filter": "vs:RegionLän07",
"values": [
"21",
"22",
"23"
]
}
},
{
"code": "Organisation",
"selection": {
"filter": "item",
"values": [
"30"
]
}
},
{
"code": "Tid",
"selection": {
"filter": "item",
"values": [
"2011"
]
}
}
],
"response": {
"format": "px"
}
}