Skip to content

Commit a022e1b

Browse files
authored
Merge pull request #386 from dimagi/warehouse-args
Fix update_warehouse command to use --start-date and --end-date options
2 parents 3d84a79 + 2098cd2 commit a022e1b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ex-submodules/django-datawarehouse/warehouse/management/commands/update_warehouse.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@
77
class Command(BaseCommand):
88

99
help = "Run the data warehouse"
10-
args = "<start_date> <end_date>"
11-
label = ""
1210

1311
def add_arguments(self, parser):
12+
parser.add_argument(
13+
'--start-date',
14+
dest='start_date',
15+
help='Start date for the warehouse run',
16+
default=None,
17+
)
18+
parser.add_argument(
19+
'--end-date',
20+
dest='end_date',
21+
help='End date for the warehouse run',
22+
default=None,
23+
)
1424
parser.add_argument(
1525
'--cleanup',
1626
action='store_true',
@@ -20,7 +30,7 @@ def add_arguments(self, parser):
2030
)
2131

2232
def handle(self, *args, **options):
23-
start_date = None if len(args) < 1 else string_to_datetime(args[0])
24-
end_date = None if len(args) < 2 else string_to_datetime(args[1])
33+
start_date = string_to_datetime(options["start_date"]) if options["start_date"] else None
34+
end_date = string_to_datetime(options["end_date"]) if options["end_date"] else None
2535
cleanup = options["cleanup"]
2636
return runner.update_warehouse(start_date, end_date, cleanup)

0 commit comments

Comments
 (0)