Commit 8a9edb2f authored by Bengfort's avatar Bengfort
Browse files

exclude closed participations from potential subject count

parent bf01b56b
Pipeline #12359 passed with stages
in 4 minutes and 22 seconds
......@@ -200,6 +200,10 @@ class StudyDetailView(PermissionRequiredMixin, DetailView):
Subject.objects.filter(
filter_queries.study(self.object),
filter_queries.has_consent()
).exclude(
pk__in=self.object.participation_set.filter(
status__in=[Participation.INVITED, Participation.UNSUITABLE]
).values('subject')
).count()
)
context['related_studies'] = list(get_related_studies(self.object))
......
......@@ -37,6 +37,7 @@ from castellum.recruitment.forms import SubjectFilterAddForm
from castellum.recruitment.forms import SubjectFilterForm
from castellum.recruitment.forms import SubjectFilterFormSet
from castellum.recruitment.models import AttributeDescription
from castellum.recruitment.models import Participation
from castellum.recruitment.models import SubjectFilter
from castellum.recruitment.models import SubjectFilterGroup
from castellum.subjects.models import Subject
......@@ -80,6 +81,10 @@ class FilterGroupListView(FilterMixin, ListView):
Subject.objects.filter(
filter_queries.study(self.study),
filter_queries.has_consent()
).exclude(
pk__in=self.study.participation_set.filter(
status__in=[Participation.INVITED, Participation.UNSUITABLE]
).values('subject')
).count()
)
context['expected_subject_factor'] = settings.CASTELLUM_EXPECTED_SUBJECT_FACTOR
......@@ -163,7 +168,16 @@ class FilterGroupUpdateView(FilterMixin, UpdateView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['count'] = self.object.get_matches().count()
context['count'] = (
self.object
.get_matches()
.exclude(
pk__in=self.study.participation_set.filter(
status__in=[Participation.INVITED, Participation.UNSUITABLE]
).values('subject')
)
.count()
)
context['total_count'] = Subject.objects.count()
context['expected_subject_factor'] = settings.CASTELLUM_EXPECTED_SUBJECT_FACTOR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment