mysociety / local-intelligence-hub

https://www.localintelligencehub.com
Other
6 stars 2 forks source link

standardise much more of the import code #343

Open struan opened 1 year ago

struan commented 1 year ago

There's still lots of repeated code in the import commands which could be moved out into a common framework.

We should do some work to make all import commands have a common structure to make changes across all of them easier to do. They should all certainly be classes that inherit from the BaseImporter class, and exist outside of the management commands. Need to think a bit more about the structure of this.

Ideally we should probably have a single run_import management command that takes an argument that is the import to run. For bonus points possibly the import should also take an area type argument.

Not sure quite what this would looks like at the moment but it should also enable a more programatic approach to running all imports.

I can see two options for the latter:

The former seems potentially better as for very standard imports it could all be in config with no need for extra code, although a quick skim of the code makes it looks like there's very few this would apply to.

A stretch goal would be for the config file to be a source for a run on deploy command that populates the database with the list of imports, and the import command pulls the list of imports from the database. The advantage of this is it'd be a reasonable first step in to a) allowing user imports and b) being able to re-import things without server access.

struan commented 11 months ago

Some more thoughts on this: