4541 Introduced clean_up_docket_judges command to clean up assigned_to and referred_to #4555
+169
−27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #4541, this PR introduces the
clean_up_docket_judges
command to clean upassigned_to
andreferred_to
fields when their correspondingassigned_to_str
andreferred_to_str
values have changed, and we don't have the new judges in database.This works by checking all the dockets in the database where
referred_to
andassigned_to
are notnull
. Then, the docketassigned_to_str
andreferred_to_str
values are used to perform a Judge lookup usinglookup_judge_by_full_name
.If the current
assigned_to
andreferred_to
values are different from the ones returned by the lookup (which includes aNone
value in case the Judge is not found), the docket is updated.Since this
save()
will trigger an Elasticsearch update, it's better to do it slowly. I set a default sleep of 0.1 seconds between each update. We can monitor how this performs and adjust the wait time between iterations accordingly.The command can be run as:
manage.py clean_up_docket_judges --iteration-wait 0.1