|
4 | 4 | from django.core.files.uploadedfile import InMemoryUploadedFile |
5 | 5 | from collections import defaultdict |
6 | 6 |
|
7 | | -from django.db.models import Q, Case, When, Value, BooleanField |
| 7 | +from django.db.models import Q, Value, BooleanField |
8 | 8 | from django.db import transaction |
9 | 9 |
|
10 | 10 | from rest_framework import status |
|
17 | 17 |
|
18 | 18 | from api.pagination import BasicPagination |
19 | 19 | from api.serializers import tasks as serializers |
20 | | -from competitions.models import Submission, Phase |
| 20 | +from competitions.models import Phase |
21 | 21 | from profiles.models import User |
22 | 22 | from tasks.models import Task |
23 | 23 | from datasets.models import Data |
@@ -53,40 +53,10 @@ def get_queryset(self): |
53 | 53 | # the public task to the user and hence we check the `retrieve` action |
54 | 54 | if self.request.query_params.get('public') or self.action == 'retrieve': |
55 | 55 | task_filter |= Q(is_public=True) |
56 | | - |
| 56 | + # Removed the "task validation" process (https://github.com/codalab/codabench/pull/1962) |
| 57 | + # We now always set "validated" to False. The "task validation" was only partly implemented and never used. |
57 | 58 | qs = qs.filter(task_filter) |
58 | | - # Determine whether a task is "valid" by finding some solution with a |
59 | | - # passing submission |
60 | | - # !CONCERN! |
61 | | - # We are looping through all tasks and potentially storing in memory. |
62 | | - # Should we potentially change "Task.objects.prefetch_related" to |
63 | | - # have similar filters as "qs" so as not to have all tasks in the db |
64 | | - # in memory. |
65 | | - # !CONCERN! |
66 | | - tasks_with_solutions = Task.objects.prefetch_related("solutions") |
67 | | - task_validations = {} |
68 | | - for task in tasks_with_solutions: |
69 | | - solution_md5s = task.solutions.values_list("md5", flat=True) |
70 | | - is_valid = Submission.objects.filter( |
71 | | - md5__in=solution_md5s, |
72 | | - status=Submission.FINISHED, |
73 | | - ).exists() |
74 | | - task_validations[task.id] = is_valid |
75 | | - |
76 | | - # Annotate queryset with validation results |
77 | | - cases = [ |
78 | | - When(id=task_id, then=Value(validated)) |
79 | | - for task_id, validated in task_validations.items() |
80 | | - ] |
81 | | - # The qs has a task in it right now. |
82 | | - # Baked into cases is task_id from task_validations. |
83 | | - # So if any of the tasks in qs, that are up for consideration, |
84 | | - # match a task from task_validations, then grab that task's |
85 | | - # validation status and return so that this task in qs now |
86 | | - # has a "validated" attribute we can access later in |
87 | | - # src/apps/api/tests/test_tasks.py as resp.data["validated"]. |
88 | | - qs = qs.annotate(validated=Case(*cases, default=Value(False), output_field=BooleanField())) |
89 | | - |
| 59 | + qs = qs.annotate(validated=Value(False, output_field=BooleanField())) |
90 | 60 | return qs.order_by('-created_when').distinct() |
91 | 61 |
|
92 | 62 | def get_serializer_class(self): |
|
0 commit comments