-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2914 from GSA-TTS/main
- Loading branch information
Showing
25 changed files
with
423 additions
and
2,264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
backend/census_historical_migration/management/commands/run_paginated_migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from ...historic_data_loader import load_historic_data_for_year | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
import logging | ||
import sys | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.WARNING) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = """ | ||
Migrate from Census tables to GSAFAC tables for a given year using pagination | ||
Usage: | ||
manage.py run_migration | ||
--year <audit year> | ||
--pageSize <page size> | ||
--pages <comma separated pages> | ||
""" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument("--year", help="4-digit Audit Year") | ||
parser.add_argument("--page_size", type=int, required=False, default=5) | ||
parser.add_argument("--pages", type=str, required=False, default="1") | ||
|
||
def handle(self, *args, **options): | ||
year = options.get("year") | ||
if not year: | ||
print("Please specify an audit year") | ||
return | ||
|
||
try: | ||
pages_str = options["pages"] | ||
pages = list(map(lambda d: int(d), pages_str.split(","))) | ||
except ValueError: | ||
logger.error(f"Found a non-integer in pages '{pages_str}'") | ||
sys.exit(-1) | ||
|
||
load_historic_data_for_year(year, options["page_size"], pages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.