mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-06 12:37:23 +02:00
Add documentation
This commit is contained in:
parent
e853d4ef16
commit
0ce4a04b4b
2 changed files with 65 additions and 1 deletions
|
@ -421,3 +421,55 @@ purposes
|
||||||
|
|
||||||
Used by the migration scripts to trigger a prompt for deleting all table entries.
|
Used by the migration scripts to trigger a prompt for deleting all table entries.
|
||||||
Useful for testing purposes, but *use with caution*
|
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. |
|
||||||
|
|
|
@ -35,11 +35,13 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
parser.add_argument("--directory", default="migrationdata", help="Desired directory")
|
||||||
|
|
||||||
|
# Serves as a domain_additional_filename override
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--domain_additional_filename",
|
"--domain_additional_filename",
|
||||||
help="Defines the filename for additional domain data",
|
help="Defines the filename for additional domain data",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Serves as a organization_adhoc_filename override
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--organization_adhoc_filename",
|
"--organization_adhoc_filename",
|
||||||
help="Defines the filename for domain type adhocs",
|
help="Defines the filename for domain type adhocs",
|
||||||
|
@ -56,8 +58,18 @@ class Command(BaseCommand):
|
||||||
# load JSON object as a dictionary
|
# load JSON object as a dictionary
|
||||||
try:
|
try:
|
||||||
data = json.load(jsonFile)
|
data = json.load(jsonFile)
|
||||||
|
|
||||||
|
skipped_fields = ["domain_additional_filename", "organization_adhoc_filename"]
|
||||||
# Iterate over the data from the JSON file. Skip any unused values.
|
# 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:
|
except Exception as err:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"{TerminalColors.FAIL}"
|
f"{TerminalColors.FAIL}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue