File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ def progress(self, project):
79
79
docs = project .documents
80
80
annotation_class = project .get_annotation_class ()
81
81
total = docs .count ()
82
- done = annotation_class .objects .filter (document_id__in = docs .all ()).\
82
+ done = annotation_class .objects .filter (document_id__in = docs .all (),
83
+ user_id = self .request .user ).\
83
84
aggregate (Count ('document' , distinct = True ))['document__count' ]
84
85
remaining = total - done
85
86
return {'total' : total , 'remaining' : remaining }
Original file line number Diff line number Diff line change 1
- from django .db .models import Count
1
+ from django .db .models import Count , Q
2
2
from django_filters .rest_framework import FilterSet , BooleanFilter
3
3
from .models import Document
4
4
@@ -9,7 +9,9 @@ class DocumentFilter(FilterSet):
9
9
seq2seq_annotations__isnull = BooleanFilter (field_name = 'seq2seq_annotations' , method = 'filter_annotations' )
10
10
11
11
def filter_annotations (self , queryset , field_name , value ):
12
- queryset = queryset .annotate (num_annotations = Count (field_name ))
12
+ queryset = queryset .annotate (num_annotations =
13
+ Count (field_name , filter =
14
+ Q (** { f"{ field_name } __user" : self .request .user })))
13
15
14
16
should_have_annotations = not value
15
17
if should_have_annotations :
Original file line number Diff line number Diff line change @@ -1039,7 +1039,7 @@ def setUpTestData(cls):
1039
1039
main_project = mommy .make ('server.TextClassificationProject' , users = [super_user ])
1040
1040
doc1 = mommy .make ('server.Document' , project = main_project )
1041
1041
doc2 = mommy .make ('server.Document' , project = main_project )
1042
- mommy .make ('DocumentAnnotation' , document = doc1 )
1042
+ mommy .make ('DocumentAnnotation' , document = doc1 , user = super_user )
1043
1043
cls .url = reverse (viewname = 'statistics' , args = [main_project .id ])
1044
1044
cls .doc = Document .objects .filter (project = main_project )
1045
1045
You can’t perform that action at this time.
0 commit comments