Add documentation

This commit is contained in:
zandercymatics 2023-11-20 10:14:10 -07:00
parent e853d4ef16
commit 0ce4a04b4b
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 65 additions and 1 deletions

View file

@ -421,3 +421,55 @@ purposes
Used by the migration scripts to trigger a prompt for deleting all table entries.
Useful for testing purposes, but *use with caution*
## Import organization data
During MVP, our import scripts did not populate the following fields: `address_line, city, state_territory, and zipcode`. This was primarily due to time constraints. Because of this, we need to run a follow-on script to load this remaining data on each `DomainInformation` object.
This script is intended to run under the assumption that the [load_transition_domain](#step-1-load-transition-domains) and the [transfer_transition_domains_to_domains](#step-2-transfer-transition-domain-data-into-main-domain-tables) scripts have already been ran.
##### LOCAL COMMAND
to run this command locally, enter the following:
```shell
docker compose run -T app ./manage.py load_organization_data {filename_of_migration_json} --debug
```
* filename_of_migration_filepath_json - This is a [JSON containing a list of filenames](#step-2-obtain-json-file-for-file-locations). This same file was used in the preceeding steps, `load_transition_domain` and `transfer_transition_domains_to_domains`, however, this script only needs two fields:
```
{
"domain_additional_filename": "example.domainadditionaldatalink.adhoc.dotgov.txt",
"organization_adhoc_filename": "example.organization.adhoc.dotgov.txt"
}
```
If you already possess the old JSON, you do not need to modify it. This script can run even if you specify multiple filepaths. It will just skip over unused ones.
**Example**
```shell
docker compose run -T app ./manage.py load_organization_data migrationFilepaths.json --debug
```
##### SANDBOX COMMAND
```shell
./manage.py load_organization_data {filename_of_migration_json} --debug
```
* **filename_of_migration_filepath_json** - This is a [JSON containing a list of filenames](#step-2-obtain-json-file-for-file-locations). This same file was used in the preceeding steps, `load_transition_domain` and `transfer_transition_domains_to_domains`, however, this script only needs two fields:
```
{
"domain_additional_filename": "example.domainadditionaldatalink.adhoc.dotgov.txt",
"organization_adhoc_filename": "example.organization.adhoc.dotgov.txt"
}
```
If you already possess the old JSON, you do not need to modify it. This script can run even if you specify multiple filepaths. It will just skip over unused ones.
**Example**
```shell
./manage.py load_organization_data migrationFilepaths.json --debug
```
##### Optional parameters
The `load_organization_data` script has five optional parameters. These are as follows:
| | Parameter | Description |
|:-:|:---------------------------------|:----------------------------------------------------------------------------|
| 1 | **sep** | Determines the file separator. Defaults to "\|" |
| 2 | **debug** | Increases logging detail. Defaults to False |
| 3 | **directory** | Specifies the containing directory of the data. Defaults to "migrationdata" |
| 4 | **domain_additional_filename** | Specifies the filename of domain_additional. Used as an override for the JSON. Has no default. |
| 5 | **organization_adhoc_filename** | Specifies the filename of organization_adhoc. Used as an override for the JSON. Has no default. |

View file

@ -35,11 +35,13 @@ class Command(BaseCommand):
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
# Serves as a domain_additional_filename override
parser.add_argument(
"--domain_additional_filename",
help="Defines the filename for additional domain data",
)
# Serves as a organization_adhoc_filename override
parser.add_argument(
"--organization_adhoc_filename",
help="Defines the filename for domain type adhocs",
@ -56,8 +58,18 @@ class Command(BaseCommand):
# load JSON object as a dictionary
try:
data = json.load(jsonFile)
skipped_fields = ["domain_additional_filename", "organization_adhoc_filename"]
# Iterate over the data from the JSON file. Skip any unused values.
options.update({key: value for key, value in data.items() if value is not None and value.strip() != ""})
for key, value in data.items():
if value is not None or value.strip() != "":
continue
# If any key in skipped_fields has a value, then
# we override what is specified in the JSON.
if key not in skipped_fields:
options[key] = value
except Exception as err:
logger.error(
f"{TerminalColors.FAIL}"