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

Commit

Permalink
Include replicate_count and positive_count fields in summary statisti…
Browse files Browse the repository at this point in the history
…cs report when percent_positive field is requested without one or both of them
  • Loading branch information
aaronstephenson committed May 13, 2019
1 parent 852a3d5 commit b03046b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lideservices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,12 +843,12 @@ def summary_statistics(self, request):
totals = {'target_name': 'All targets', 'target_id': None}

# calculate the requested statistics per object
if 'replicate_count' in statistic_list:
# queryset = queryset.annotate(replicate_count=Count(Subquery(all_reps.values('id'))))
if ('replicate_count' in statistic_list
or ('percent_positive' in statistic_list and 'replicate_count' not in statistic_list)):
queryset = queryset.annotate(replicate_count=Count('id'))
totals['replicate_count'] = queryset.aggregate(Sum('replicate_count'))['replicate_count__sum']
if 'positive_count' in statistic_list:
# queryset = queryset.annotate(positive_count=Count(Subquery(pos_reps.values('id'))))
if ('positive_count' in statistic_list
or ('percent_positive' in statistic_list and 'positive_count' not in statistic_list)):
queryset = queryset.annotate(positive_count=Count('id', filter=Q(replicate_concentration__gt=0)))
totals['positive_count'] = queryset.aggregate(Sum('positive_count'))['positive_count__sum']
if 'percent_positive' in statistic_list:
Expand Down

0 comments on commit b03046b

Please sign in to comment.