We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Wrong progress in collaborative annotation ('Share annotations across all users')
How to reproduce the behaviour
---------
Progress is shown as individual progress instead of total progress when 'Share annotations across all users' is ticked in project setting.

Your Environment
---------
<!-- Include details of your environment.-->
*   Operating System: wsl2+ubuntu20.04
*   Python Version Used: 3.8
*   When you install doccano: 20220403
*   How did you install doccano (Heroku button etc): source


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `backend/metrics/views.py`
Content:
```
1 import abc
2 
3 from rest_framework import status
4 from rest_framework.permissions import IsAuthenticated
5 from rest_framework.response import Response
6 from rest_framework.views import APIView
7 
8 from examples.models import Example, ExampleState
9 from label_types.models import CategoryType, LabelType, RelationType, SpanType
10 from labels.models import Category, Label, Relation, Span
11 from projects.models import Member
12 from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
13 
14 
15 class ProgressAPI(APIView):
16     permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]
17 
18     def get(self, request, *args, **kwargs):
19         examples = Example.objects.filter(project=self.kwargs["project_id"]).values("id")
20         total = examples.count()
21         complete = ExampleState.objects.count_done(examples, user=self.request.user)
22         data = {"total": total, "remaining": total - complete, "complete": complete}
23         return Response(data=data, status=status.HTTP_200_OK)
24 
25 
26 class MemberProgressAPI(APIView):
27     permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]
28 
29     def get(self, request, *args, **kwargs):
30         examples = Example.objects.filter(project=self.kwargs["project_id"]).values("id")
31         members = Member.objects.filter(project=self.kwargs["project_id"])
32         data = ExampleState.objects.measure_member_progress(examples, members)
33         return Response(data=data, status=status.HTTP_200_OK)
34 
35 
36 class LabelDistribution(abc.ABC, APIView):
37     permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]
38     model = Label
39     label_type = LabelType
40 
41     def get(self, request, *args, **kwargs):
42         labels = self.label_type.objects.filter(project=self.kwargs["project_id"])
43         examples = Example.objects.filter(project=self.kwargs["project_id"]).values("id")
44         members = Member.objects.filter(project=self.kwargs["project_id"])
45         data = self.model.objects.calc_label_distribution(examples, members, labels)
46         return Response(data=data, status=status.HTTP_200_OK)
47 
48 
49 class CategoryTypeDistribution(LabelDistribution):
50     model = Category
51     label_type = CategoryType
52 
53 
54 class SpanTypeDistribution(LabelDistribution):
55     model = Span
56     label_type = SpanType
57 
58 
59 class RelationTypeDistribution(LabelDistribution):
60     model = Relation
61     label_type = RelationType
62
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/backend/metrics/views.py b/backend/metrics/views.py
--- a/backend/metrics/views.py
+++ b/backend/metrics/views.py
@@ -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
@@ -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
 
 
@@ -18,7 +19,11 @@
     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)

{"golden_diff": "diff --git a/backend/metrics/views.py b/backend/metrics/views.py\n--- a/backend/metrics/views.py\n+++ b/backend/metrics/views.py\n@@ -1,5 +1,6 @@\n import abc\n \n+from django.shortcuts import get_object_or_404\n from rest_framework import status\n from rest_framework.permissions import IsAuthenticated\n from rest_framework.response import Response\n@@ -8,7 +9,7 @@\n from examples.models import Example, ExampleState\n from label_types.models import CategoryType, LabelType, RelationType, SpanType\n from labels.models import Category, Label, Relation, Span\n-from projects.models import Member\n+from projects.models import Member, Project\n from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly\n \n \n@@ -18,7 +19,11 @@\n     def get(self, request, *args, **kwargs):\n         examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n         total = examples.count()\n-        complete = ExampleState.objects.count_done(examples, user=self.request.user)\n+        project = get_object_or_404(Project, pk=self.kwargs[\"project_id\"])\n+        if project.collaborative_annotation:\n+            complete = ExampleState.objects.count_done(examples)\n+        else:\n+            complete = ExampleState.objects.count_done(examples, user=self.request.user)\n         data = {\"total\": total, \"remaining\": total - complete, \"complete\": complete}\n         return Response(data=data, status=status.HTTP_200_OK)\n", "issue": "Wrong progress in collaborative annotation ('Share annotations across all users')\nHow to reproduce the behaviour\r\n---------\r\nProgress is shown as individual progress instead of total progress when 'Share annotations across all users' is ticked in project setting.\r\n\r\nYour Environment\r\n---------\r\n<!-- Include details of your environment.-->\r\n*   Operating System: wsl2+ubuntu20.04\r\n*   Python Version Used: 3.8\r\n*   When you install doccano: 20220403\r\n*   How did you install doccano (Heroku button etc): source\r\n\n", "before_files": [{"content": "import abc\n\nfrom rest_framework import status\nfrom rest_framework.permissions import IsAuthenticated\nfrom rest_framework.response import Response\nfrom rest_framework.views import APIView\n\nfrom examples.models import Example, ExampleState\nfrom label_types.models import CategoryType, LabelType, RelationType, SpanType\nfrom labels.models import Category, Label, Relation, Span\nfrom projects.models import Member\nfrom projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly\n\n\nclass ProgressAPI(APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n\n    def get(self, request, *args, **kwargs):\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        total = examples.count()\n        complete = ExampleState.objects.count_done(examples, user=self.request.user)\n        data = {\"total\": total, \"remaining\": total - complete, \"complete\": complete}\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass MemberProgressAPI(APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n\n    def get(self, request, *args, **kwargs):\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        members = Member.objects.filter(project=self.kwargs[\"project_id\"])\n        data = ExampleState.objects.measure_member_progress(examples, members)\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass LabelDistribution(abc.ABC, APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n    model = Label\n    label_type = LabelType\n\n    def get(self, request, *args, **kwargs):\n        labels = self.label_type.objects.filter(project=self.kwargs[\"project_id\"])\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        members = Member.objects.filter(project=self.kwargs[\"project_id\"])\n        data = self.model.objects.calc_label_distribution(examples, members, labels)\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass CategoryTypeDistribution(LabelDistribution):\n    model = Category\n    label_type = CategoryType\n\n\nclass SpanTypeDistribution(LabelDistribution):\n    model = Span\n    label_type = SpanType\n\n\nclass RelationTypeDistribution(LabelDistribution):\n    model = Relation\n    label_type = RelationType\n", "path": "backend/metrics/views.py"}], "after_files": [{"content": "import abc\n\nfrom django.shortcuts import get_object_or_404\nfrom rest_framework import status\nfrom rest_framework.permissions import IsAuthenticated\nfrom rest_framework.response import Response\nfrom rest_framework.views import APIView\n\nfrom examples.models import Example, ExampleState\nfrom label_types.models import CategoryType, LabelType, RelationType, SpanType\nfrom labels.models import Category, Label, Relation, Span\nfrom projects.models import Member, Project\nfrom projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly\n\n\nclass ProgressAPI(APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n\n    def get(self, request, *args, **kwargs):\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        total = examples.count()\n        project = get_object_or_404(Project, pk=self.kwargs[\"project_id\"])\n        if project.collaborative_annotation:\n            complete = ExampleState.objects.count_done(examples)\n        else:\n            complete = ExampleState.objects.count_done(examples, user=self.request.user)\n        data = {\"total\": total, \"remaining\": total - complete, \"complete\": complete}\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass MemberProgressAPI(APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n\n    def get(self, request, *args, **kwargs):\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        members = Member.objects.filter(project=self.kwargs[\"project_id\"])\n        data = ExampleState.objects.measure_member_progress(examples, members)\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass LabelDistribution(abc.ABC, APIView):\n    permission_classes = [IsAuthenticated & (IsProjectAdmin | IsProjectStaffAndReadOnly)]\n    model = Label\n    label_type = LabelType\n\n    def get(self, request, *args, **kwargs):\n        labels = self.label_type.objects.filter(project=self.kwargs[\"project_id\"])\n        examples = Example.objects.filter(project=self.kwargs[\"project_id\"]).values(\"id\")\n        members = Member.objects.filter(project=self.kwargs[\"project_id\"])\n        data = self.model.objects.calc_label_distribution(examples, members, labels)\n        return Response(data=data, status=status.HTTP_200_OK)\n\n\nclass CategoryTypeDistribution(LabelDistribution):\n    model = Category\n    label_type = CategoryType\n\n\nclass SpanTypeDistribution(LabelDistribution):\n    model = Span\n    label_type = SpanType\n\n\nclass RelationTypeDistribution(LabelDistribution):\n    model = Relation\n    label_type = RelationType\n", "path": "backend/metrics/views.py"}]}