Browse Source

Change bulk_assign to assign only unassigned examples

pull/2261/head
Hironsan 1 year ago
parent
commit
2dfc270f7f
1 changed files with 4 additions and 4 deletions
  1. 8
      backend/examples/assignment/usecase.py

8
backend/examples/assignment/usecase.py

@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404
from examples.assignment.strategies import StrategyName, create_assignment_strategy
from examples.assignment.workload import WorkloadAllocation
from examples.models import Assignment
from examples.models import Assignment, Example
from projects.models import Member, Project
@ -14,15 +14,15 @@ def bulk_assign(project_id: int, workload_allocation: WorkloadAllocation, strate
# Sort members by workload_allocation.member_ids
members = sorted(members, key=lambda m: workload_allocation.member_ids.index(m.id))
dataset_size = project.examples.count() # Todo: unassigned examples
unassigned_examples = Example.objects.filter(project=project, assignments__isnull=True)
dataset_size = unassigned_examples.count()
strategy = create_assignment_strategy(strategy_name, dataset_size, workload_allocation.weights)
assignments = strategy.assign()
examples = project.examples.all()
assignments = [
Assignment(
project=project,
example=examples[assignment.example],
example=unassigned_examples[assignment.example],
assignee=members[assignment.user].user,
)
for assignment in assignments

Loading…
Cancel
Save