File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -1331,6 +1331,12 @@ def test_returns_label_count(self):
1331
1331
self .assertIn ('user' , response .data )
1332
1332
self .assertIsInstance (response .data ['user' ], dict )
1333
1333
1334
+ def test_returns_partial_response (self ):
1335
+ self .client .login (username = self .super_user_name ,
1336
+ password = self .super_user_pass )
1337
+ response = self .client .get (f'{ self .url } ?include=user' , format = 'json' )
1338
+ self .assertEqual (list (response .data .keys ()), ['user' ])
1339
+
1334
1340
1335
1341
class TestUserAPI (APITestCase ):
1336
1342
@@ -1507,4 +1513,4 @@ def test_disallows_project_member_to_delete_mapping(self):
1507
1513
self .client .login (username = self .project_member_name ,
1508
1514
password = self .project_member_pass )
1509
1515
response = self .client .delete (self .url , format = 'json' )
1510
- self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
1516
+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
Original file line number Diff line number Diff line change @@ -68,12 +68,22 @@ class StatisticsAPI(APIView):
68
68
69
69
def get (self , request , * args , ** kwargs ):
70
70
p = get_object_or_404 (Project , pk = self .kwargs ['project_id' ])
71
- label_count , user_count = self .label_per_data (p )
72
- progress = self .progress (project = p )
73
- response = dict ()
74
- response ['label' ] = label_count
75
- response ['user' ] = user_count
76
- response .update (progress )
71
+
72
+ include = set (request .GET .getlist ('include' ))
73
+ response = {}
74
+
75
+ if not include or 'label' in include or 'user' in include :
76
+ label_count , user_count = self .label_per_data (p )
77
+ response ['label' ] = label_count
78
+ response ['user' ] = user_count
79
+
80
+ if not include or 'total' in include or 'remaining' in include :
81
+ progress = self .progress (project = p )
82
+ response .update (progress )
83
+
84
+ if include :
85
+ response = {key : value for (key , value ) in response .items () if key in include }
86
+
77
87
return Response (response )
78
88
79
89
def progress (self , project ):
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ export default {
236
236
237
237
annotations ( ) {
238
238
// fetch progress info.
239
- HTTP . get ( 'statistics' ) . then ( ( response ) => {
239
+ HTTP . get ( 'statistics?include=total&include=remaining ' ) . then ( ( response ) => {
240
240
this . total = response . data . total ;
241
241
this . remaining = response . data . remaining ;
242
242
} ) ;
You can’t perform that action at this time.
0 commit comments