diff --git a/Campaign/views.py b/Campaign/views.py index 2f326f5c..a5770b0a 100644 --- a/Campaign/views.py +++ b/Campaign/views.py @@ -264,10 +264,15 @@ def campaign_status_esa(campaign) -> str: """ out_str += f"
| {x} | " for x in ["Username", "Progress", "First Modified", "Last Modified", "Time (Last-First)", "Time (Real)"] - ) + "|||||
|---|---|---|---|---|---|
| Username | +Progress | +First Modified | +Last Modified | +Time (Coarse ❔) | +Time (Real ❔) | +{user.username} ✅ | " else: out_str += f"{user.username} 🛠️ | " - out_str += f"{len(_data)}/{total_count} ({len(_data) / total_count:.0%}) | " + out_str += f"{_data_uniq_len}/{total_count} ({_data_uniq_len / total_count:.0%}) | " first_modified = min([x.start_time for x in _data]) last_modified = max([x.end_time for x in _data]) @@ -351,15 +357,9 @@ def campaign_status_esa(campaign) -> str: annotation_time_upper = f'{int(floor(annotation_time_upper / 3600)):0>2d}h {int(floor((annotation_time_upper % 3600) / 60)):0>2d}m' out_str += f"{annotation_time_upper} | " - times = collections.defaultdict(list) - for item in _data: - times[(item.item.documentID, item.item.targetID)].append((item.start_time, item.end_time)) - times = [ - (min([x[0] for x in doc_v]), max([x[1] for x in doc_v])) - for doc, doc_v in times.items() - ] - - annotation_time = sum([b-a for a, b in times]) + # consider time that's in any action within 10 minutes + times = sorted([item.start_time for item in _data] + [item.end_time for item in _data]) + annotation_time = sum([b-a for a, b in zip(times, times[1:]) if (b-a) < 10*60]) annotation_time = f'{int(floor(annotation_time / 3600)):0>2d}h {int(floor((annotation_time % 3600) / 60)):0>2d}m' out_str += f"{annotation_time} | " diff --git a/EvalData/models/direct_assessment_document.py b/EvalData/models/direct_assessment_document.py index 2a3a56dd..97d71af5 100644 --- a/EvalData/models/direct_assessment_document.py +++ b/EvalData/models/direct_assessment_document.py @@ -599,35 +599,25 @@ def get_hit_status_for_user(cls, user): @classmethod def get_time_for_user(cls, user): results = cls.objects.filter(createdBy=user, activated=False, completed=True) + campaign_opts = result.task.campaign.campaignOptions.lower().split(";") is_esa_or_mqm = any( [ - "esa" in result.task.campaign.campaignOptions.lower().split(";") - or "mqm" in result.task.campaign.campaignOptions.lower().split(";") + "esa" in campaign_opts or "mqm" in campaign_opts for result in results ] ) if is_esa_or_mqm: - # for ESA or MQM, do minimum and maximum from each doc - import collections - - timestamps = collections.defaultdict(list) - for result in results: - timestamps[ - result.item.documentID + " ||| " + result.item.targetID - ].append((result.start_time, result.end_time)) - - # timestamps are document-level now, but that does not change anything later on - timestamps = [ - (min([x[0] for x in doc_v]), max([x[1] for x in doc_v])) - for doc, doc_v in timestamps.items() - ] + # consider time that's in any action within 10 minutes + times = sorted([item.start_time for item in results] + [item.end_time for item in results]) + annotation_time = sum([b-a for a, b in zip(times, times[1:]) if (b-a) < 10*60]) + return seconds_to_timedelta(annotation_time) else: timestamps = [] for result in results: timestamps.append((result.start_time, result.end_time)) - return seconds_to_timedelta(_compute_user_total_annotation_time(timestamps)) + return seconds_to_timedelta(_compute_user_total_annotation_time(timestamps)) @classmethod def get_system_annotations(cls):