-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
110 additions
and
21 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
emgapi/migrations/0011_analysisjob_analysis_summary_json.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,18 @@ | ||
# Generated by Django 3.2.18 on 2023-09-13 10:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('emgapi', '0010_runextraannotation'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='analysisjob', | ||
name='analysis_summary_json', | ||
field=models.JSONField(blank=True, db_column='ANALYSIS_SUMMARY_JSON', null=True), | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1021,6 +1021,7 @@ class Meta: | |
'is_suppressed', | ||
'suppressed_at', | ||
'suppression_reason', | ||
'analysis_summary_json' | ||
) | ||
|
||
|
||
|
37 changes: 37 additions & 0 deletions
37
emgapianns/management/commands/import_analysis_summaries.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,37 @@ | ||
from django.core.management.base import BaseCommand | ||
from emgapi.models import AnalysisJob | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Copy values from analysis_summary to analysis_summary_json for a specified batch of AnalysisJob records' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('batch_number', type=int, help='Batch number to process') | ||
|
||
def handle(self, *args, **options): | ||
batch_number = options['batch_number'] | ||
batch_size = 10000 | ||
|
||
try: | ||
start_index = (batch_number - 1) * batch_size | ||
end_index = batch_number * batch_size | ||
|
||
analysis_jobs = AnalysisJob.objects.all()[start_index:end_index] | ||
|
||
self.stdout.write(self.style.SUCCESS(f'Processing batch {batch_number} of {len(analysis_jobs)} records.')) | ||
|
||
updated_records = [] | ||
|
||
for analysis_job in analysis_jobs: | ||
analysis_summary = analysis_job.analysis_summary | ||
if analysis_summary and not analysis_job.analysis_summary_json: | ||
analysis_job.analysis_summary_json = analysis_summary | ||
updated_records.append(analysis_job) | ||
|
||
if updated_records: | ||
AnalysisJob.objects.bulk_update(updated_records, ['analysis_summary_json']) | ||
|
||
self.stdout.write(self.style.SUCCESS(f'Values copied successfully for batch {batch_number}.')) | ||
self.stdout.write(self.style.SUCCESS(f'Updated {len(updated_records)} records.')) | ||
except AnalysisJob.DoesNotExist: | ||
self.stdout.write(self.style.ERROR('AnalysisJob table does not exist or is empty.')) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__: str = "2.4.27" | ||
__version__: str = "2.4.33" |
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