Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LSDV-5367: Cancelled and updated annotations don't recalculate #4472

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions label_studio/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,16 +984,15 @@ def update_project_summary_annotations_and_is_labeled(sender, instance, created,
"""Update annotation counters in project summary"""
instance.increase_project_summary_counters()

if created:
# If new annotation created, update task.is_labeled state
logger.debug(f'Update task stats for task={instance.task}')
if instance.was_cancelled:
instance.task.cancelled_annotations = instance.task.annotations.all().filter(was_cancelled=True).count()
else:
instance.task.total_annotations = instance.task.annotations.all().filter(was_cancelled=False).count()
instance.task.update_is_labeled()
instance.task.save(update_fields=['is_labeled', 'total_annotations', 'cancelled_annotations'])
logger.debug(f'Updated total_annotations and cancelled_annotations for {instance.task.id}.')
# If annotation is changed, update task.is_labeled state
logger.debug(f'Update task stats for task={instance.task}')
if instance.was_cancelled:
instance.task.cancelled_annotations = instance.task.annotations.all().filter(was_cancelled=True).count()
else:
instance.task.total_annotations = instance.task.annotations.all().filter(was_cancelled=False).count()
instance.task.update_is_labeled()
instance.task.save(update_fields=['is_labeled', 'total_annotations', 'cancelled_annotations'])
logger.debug(f'Updated total_annotations and cancelled_annotations for {instance.task.id}.')


@receiver(pre_delete, sender=Prediction)
Expand Down