Skip to content

Commit

Permalink
Merge pull request #1012 from devinit/fix/update_csv_command
Browse files Browse the repository at this point in the history
Don't overwrite loop variable and turn off count rows before operatio…
  • Loading branch information
akmiller01 authored Dec 5, 2023
2 parents 6720e41 + 498b41e commit 03060e0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions data/management/commands/update_csv_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def handle(self, *args, **options):

if options['validate'] and COLUMNS_META_FILE_NAME in file_content.path:
self.stdout.write("Checking columns...", ending='\n')
self.stdout.flush()
self.check_column_mapping(options["path"])
except Exception as e:
raise CommandError(e)
Expand Down Expand Up @@ -72,20 +73,22 @@ def update_affected_columns(self, source, column):
if steps.count():
self.stdout.write("{} steps found using the obsolete {} column in the {} table".format(
steps.count(), column.name, source.active_mirror_name), ending='\n')
self.stdout.flush()
for step in steps:
operation = step.operation
columns = operation.logs.get('columns', []) if operation.logs else []
if not column.name in columns:
columns.append(column.name)
steps = operation.logs.get('steps', []) if operation.logs else []
if not step.step_id in steps:
steps.append(step.step_id)
log_steps = operation.logs.get('steps', []) if operation.logs else []
if not step.step_id in log_steps:
log_steps.append(step.step_id)
operation.logs = {
'type': 'warning',
'message': 'Obsolete Columns',
'columns': columns,
'steps': steps
'steps': log_steps
}
operation.count_rows = False
operation.save()

step_columns = step.logs.get('columns', []) if step.logs else []
Expand Down

0 comments on commit 03060e0

Please sign in to comment.