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

show total progress if collaborative_annotation #1770

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Changes from 1 commit
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
Next Next commit
show total progress if collaborative_annotation
  • Loading branch information
mkmark committed Apr 5, 2022
commit fdce902f9947cc7b5c94b88c21857676a0db5ba6
9 changes: 7 additions & 2 deletions backend/metrics/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import abc

from django.shortcuts import get_object_or_404
from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
Expand All @@ -8,7 +9,7 @@
from examples.models import Example, ExampleState
from label_types.models import CategoryType, LabelType, RelationType, SpanType
from labels.models import Category, Label, Relation, Span
from projects.models import Member
from projects.models import Member, Project
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly


Expand All @@ -18,7 +19,11 @@ class ProgressAPI(APIView):
def get(self, request, *args, **kwargs):
examples = Example.objects.filter(project=self.kwargs["project_id"]).values("id")
total = examples.count()
complete = ExampleState.objects.count_done(examples, user=self.request.user)
project = get_object_or_404(Project, pk=self.kwargs["project_id"])
if project.collaborative_annotation:
complete = ExampleState.objects.count_done(examples)
else:
complete = ExampleState.objects.count_done(examples, user=self.request.user)
data = {"total": total, "remaining": total - complete, "complete": complete}
return Response(data=data, status=status.HTTP_200_OK)

Expand Down