@@ -355,15 +355,24 @@ public Map<String, Integer> statsMediaAssets() {
355
355
356
356
public JSONObject statsAnnotations (Shepherd myShepherd ) {
357
357
JSONObject sa = new JSONObject ();
358
+ // List<Task> is ordered 'created desc'
358
359
Map <Annotation , List <Task > > atm = this .getAnnotationTaskMap (myShepherd );
359
360
int numTasks = 0 ;
361
+ int numLatestTasks = 0 ;
360
362
JSONObject encData = new JSONObject ();
361
363
362
364
for (Annotation ann : atm .keySet ()) {
363
365
Encounter enc = ann .findEncounter (myShepherd );
364
366
if ((enc != null ) && !encData .has (enc .getId ()))
365
367
encData .put (enc .getId (), new JSONArray ());
368
+ // trivial annots will not be sent correctly to ident (no iaClass etc)
369
+ // so we skip them in counts as if not sent
370
+ if (ann .isTrivial ()) {
371
+ sa .put (ann .getId (), 0 );
372
+ continue ;
373
+ }
366
374
sa .put (ann .getId (), Util .collectionSize (atm .get (ann )));
375
+ boolean latestTask = true ; // only for first (most recent) task
367
376
for (Task atask : atm .get (ann )) {
368
377
String status = atask .getStatus (myShepherd );
369
378
if (sa .has (status )) {
@@ -372,17 +381,29 @@ public JSONObject statsAnnotations(Shepherd myShepherd) {
372
381
sa .put (status , 1 );
373
382
}
374
383
numTasks ++;
384
+ // this records only most recent task statuses like: numLatestTask_complete
385
+ if (latestTask ) {
386
+ String latestStatus = "numLatestTask_" + atask .getStatus (myShepherd );
387
+ if (sa .has (latestStatus )) {
388
+ sa .put (latestStatus , sa .optInt (latestStatus , 0 ) + 1 );
389
+ } else {
390
+ sa .put (latestStatus , 1 );
391
+ }
392
+ numLatestTasks ++;
393
+ }
375
394
if (enc != null ) {
376
395
JSONArray arr = new JSONArray ();
377
396
arr .put (atask .getId ());
378
397
arr .put (status );
379
398
arr .put (ann .getIAClass ());
380
399
encData .getJSONArray (enc .getId ()).put (arr );
381
400
}
401
+ latestTask = false ;
382
402
}
383
403
}
384
404
sa .put ("encounterTaskInfo" , encData );
385
405
sa .put ("numTasks" , numTasks );
406
+ sa .put ("numLatestTasks" , numLatestTasks );
386
407
return sa ;
387
408
}
388
409
@@ -553,12 +574,12 @@ public JSONObject iaSummaryJson(Shepherd myShepherd) {
553
574
int numIdentificationComplete = 0 ;
554
575
int numIdentificationTotal = 0 ;
555
576
// getOverallStatus() in imports.jsp is a nightmare. attempt to replicate here.
556
- if (statsAnn .optInt ("numTasks " , -1 ) >= 0 )
557
- numIdentificationTotal = statsAnn .optInt ("numTasks " );
577
+ if (statsAnn .optInt ("numLatestTasks " , -1 ) >= 0 )
578
+ numIdentificationTotal = statsAnn .optInt ("numLatestTasks " );
558
579
// who is the genius who made this be 'completed' versus the (seemingly universal?) 'complete'
559
580
// (it may well have been me)
560
- if (statsAnn .optInt ("completed " , -1 ) >= 0 )
561
- numIdentificationComplete = statsAnn .optInt ("completed " );
581
+ if (statsAnn .optInt ("numLatestTask_completed " , -1 ) >= 0 )
582
+ numIdentificationComplete = statsAnn .optInt ("numLatestTask_completed " );
562
583
// TODO do we have to deal with errors as "completed" somehow?
563
584
pj .put ("identificationNumberComplete" , numIdentificationComplete );
564
585
pj .put ("identificationNumTotal" , numIdentificationTotal );
0 commit comments