2121from EvalData .models import DirectAssessmentDocumentResult
2222from EvalData .models import PairwiseAssessmentDocumentResult
2323from EvalData .models import PairwiseAssessmentResult
24- from EvalData .models import seconds_to_timedelta
2524from EvalData .models import TASK_DEFINITIONS
2625from EvalData .models import TaskAgenda
2726from EvalData .models .direct_assessment_document import DirectAssessmentDocumentTask
@@ -48,7 +47,7 @@ def _format_timestamp_strings(epoch_seconds):
4847 if epoch_seconds is None :
4948 return ('Never' , '' )
5049
51- dt_value = datetime ( 1970 , 1 , 1 ) + seconds_to_timedelta (epoch_seconds )
50+ dt_value = datetime . fromtimestamp (epoch_seconds )
5251 full_value = str (dt_value ).split ('.' )[0 ]
5352 trimmed_value = ':' .join (full_value .split (':' )[:- 1 ])
5453 return (full_value , trimmed_value )
@@ -204,8 +203,8 @@ def _collect_campaign_status_rows(campaign, result_type, campaign_opts):
204203
205204 reliability = stat_reliable_testing (data_rows , campaign_opts , result_type )
206205 annotations = len ({row [6 ] for row in data_rows })
207- start_times = [row [0 ] for row in data_rows ]
208- end_times = [row [1 ] for row in data_rows ]
206+ start_times = [row [0 ] for row in data_rows if row [ 0 ] > 0 ]
207+ end_times = [row [1 ] for row in data_rows if row [ 1 ] > 0 ]
209208 first_epoch = min (start_times ) if start_times else None
210209 last_epoch = max (end_times ) if end_times else None
211210 first_full , first_trim = _format_timestamp_strings (first_epoch )
@@ -582,11 +581,11 @@ def campaign_status_esa(campaign) -> str:
582581 else :
583582 out_str += f"<td>{ user .username } 🛠️</td>"
584583 out_str += f"<td>{ _data_uniq_len } /{ total_count } ({ _data_uniq_len / total_count :.0%} )</td>"
585- first_modified = min ([x .start_time for x in _data ])
586- last_modified = max ([x .end_time for x in _data ])
584+ first_modified = min ([x .start_time for x in _data if x . start_time > 0 ])
585+ last_modified = max ([x .end_time for x in _data if x . end_time > 0 ])
587586
588- first_modified_str = str (datetime ( 1970 , 1 , 1 ) + seconds_to_timedelta (first_modified )).split ('.' )[0 ]
589- last_modified_str = str (datetime ( 1970 , 1 , 1 ) + seconds_to_timedelta (last_modified )).split ('.' )[0 ]
587+ first_modified_str = str (datetime . fromtimestamp (first_modified )).split ('.' )[0 ]
588+ last_modified_str = str (datetime . fromtimestamp (last_modified )).split ('.' )[0 ]
590589 # remove seconds
591590 first_modified_str = ":" .join (first_modified_str .split (":" )[:- 1 ])
592591 last_modified_str = ":" .join (last_modified_str .split (":" )[:- 1 ])
@@ -598,7 +597,7 @@ def campaign_status_esa(campaign) -> str:
598597 out_str += f"<td>{ annotation_time_upper } </td>"
599598
600599 # consider time that's in any action within 10 minutes
601- times = sorted ([item . start_time for item in _data ] + [item .end_time for item in _data ])
600+ times = sorted ([t for item in _data for t in [item .start_time , item . end_time ] if t > 0 ])
602601 annotation_time = sum ([b - a for a , b in zip (times , times [1 :]) if (b - a ) < 10 * 60 ])
603602 annotation_time = f'{ int (floor (annotation_time / 3600 )):0>2d} h { int (floor ((annotation_time % 3600 ) / 60 )):0>2d} m'
604603
0 commit comments