mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-30 22:46:30 +02:00
Test performance upgrade
This commit is contained in:
parent
9d20769e6e
commit
20bde7df39
4 changed files with 53 additions and 34 deletions
|
@ -87,7 +87,7 @@ class PopulateScriptTemplate(ABC):
|
|||
raise NotImplementedError
|
||||
|
||||
def mass_update_records(
|
||||
self, object_class, filter_conditions, fields_to_update, debug=True, verbose=False, skip_bulk_update=False
|
||||
self, object_class, filter_conditions, fields_to_update, debug=True, verbose=False
|
||||
):
|
||||
"""Loops through each valid "object_class" object - specified by filter_conditions - and
|
||||
updates fields defined by fields_to_update using update_record.
|
||||
|
@ -108,11 +108,6 @@ class PopulateScriptTemplate(ABC):
|
|||
verbose: Whether to print a detailed run summary *before* run confirmation.
|
||||
Default: False.
|
||||
|
||||
skip_bulk_update: Whether to avoid doing a bulk update or not.
|
||||
This setting assumes that you are doing a save in the update_record class.
|
||||
IMPORANT: this setting invalidates 'fields_to_update'.
|
||||
Default: False
|
||||
|
||||
Raises:
|
||||
NotImplementedError: If you do not define update_record before using this function.
|
||||
TypeError: If custom_filter is not Callable.
|
||||
|
@ -162,8 +157,7 @@ class PopulateScriptTemplate(ABC):
|
|||
logger.error(fail_message)
|
||||
|
||||
# Do a bulk update on the desired field
|
||||
if not skip_bulk_update:
|
||||
ScriptDataHelper.bulk_update_fields(object_class, to_update, fields_to_update)
|
||||
self.bulk_update_fields(object_class, to_update, fields_to_update)
|
||||
|
||||
# Log what happened
|
||||
TerminalHelper.log_script_run_summary(
|
||||
|
@ -175,6 +169,9 @@ class PopulateScriptTemplate(ABC):
|
|||
display_as_str=True,
|
||||
)
|
||||
|
||||
def bulk_update_fields(self, object_class, to_update, fields_to_update):
|
||||
ScriptDataHelper.bulk_update_fields(object_class, to_update, fields_to_update)
|
||||
|
||||
def get_class_name(self, sender) -> str:
|
||||
"""Returns the class name that we want to display for the terminal prompt.
|
||||
Example: DomainRequest => "Domain Request"
|
||||
|
@ -472,4 +469,4 @@ class TerminalHelper:
|
|||
terminal_color = color
|
||||
|
||||
colored_message = f"{terminal_color}{message}{TerminalColors.ENDC}"
|
||||
log_method(colored_message, exc_info=exc_info)
|
||||
return log_method(colored_message, exc_info=exc_info)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue