Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Implement PCR Replicate recalculations on all relevant report requests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronstephenson committed Jul 25, 2019
1 parent 4d105db commit dde0bfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "lide",
"organization": "U.S. Geological Survey",
"description": "Web services for LILI (LIDE (Laboratory for Infectious Disease and the Environment) Information Management System)",
"version": "v0.110.0",
"version": "v0.111.0",
"status": "Release Candidate",

"permissions": {
Expand Down
19 changes: 19 additions & 0 deletions lideservices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ def inhibition_report(self, request):
queryset = queryset.filter(sample__in=sample_list)
else:
queryset = queryset.filter(sample__exact=sample)
# recalc not needed here because the report shows inhibition data, not PCR replicate data
# # recalc reps
# for sampleext in queryset:
# recalc_reps('SampleExtraction', sampleext.id)
Expand Down Expand Up @@ -1521,6 +1522,11 @@ def post(self, request):
samples = request_data.get('samples', None)
if samples is not None:
queryset = queryset.filter(id__in=samples)

# recalc reps
for sample in queryset:
recalc_reps('Sample', sample.id)

matrix_counts = queryset.values('matrix__name').order_by().annotate(count=Count('matrix'))
sample_type_counts = queryset.values('sample_type__name').order_by().annotate(count=Count('sample_type'))
total_volume_sampled_unit_initial_counts = queryset.values(
Expand Down Expand Up @@ -1590,6 +1596,10 @@ def post(self, request):
else:
eb_raw_data = ExtractionBatch.objects.all()

# recalc reps
for eb in eb_raw_data:
recalc_reps('ExtractionBatch', eb.id)

eb_raw_data = eb_raw_data.filter(reversetranscriptions__re_rt__isnull=True).annotate(
rt_template_volume=F('reversetranscriptions__template_volume'))
eb_raw_data = eb_raw_data.filter(reversetranscriptions__re_rt__isnull=True).annotate(
Expand Down Expand Up @@ -1666,6 +1676,15 @@ def post(self, request):
targets = Target.objects.filter(id__in=target_ids).values('id', 'name').order_by('name')
target_names = [target['name'] for target in targets]

# recalc reps once for use by all the control queries below
queryset = PCRReplicateBatch.objects.all()
if sample_ids:
queryset = queryset.filter(pcrreplicates__sample_extraction__sample__in=sample_ids)
if target_ids:
queryset = queryset.filter(target__in=target_ids)
for pcrrep_batch in queryset:
recalc_reps('PCRReplicateBatch', pcrrep_batch.id)

pos = "Positive"
neg = "Negative"
nr = "No Result"
Expand Down

0 comments on commit dde0bfb

Please sign in to comment.