Skip to content

Commit

Permalink
Excludes completed tasks/projects from autostaffing. (#762)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Haas <dhaas@b12.io>
  • Loading branch information
thisisdhaas and Daniel Haas committed Mar 26, 2021
1 parent 2ed2658 commit 321a56c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions orchestra/communication/staffing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,21 @@ def check_responses_complete(request):
.format(request.task)))


def _exclude_inactive_staffbot_requests(request_queryset):
return (request_queryset
.exclude(status=StaffBotRequest.Status.CLOSED.value)
.exclude(task__project__status=Project.Status.COMPLETED)
.exclude(task__project__status=Project.Status.ABORTED)
.exclude(task__status=Task.Status.COMPLETE)
.exclude(task__status=Task.Status.ABORTED))


def address_staffing_requests(
worker_batch_size=settings.ORCHESTRA_STAFFBOT_WORKER_BATCH_SIZE,
frequency=settings.ORCHESTRA_STAFFBOT_BATCH_FREQUENCY):
staffbot = StaffBot()
cutoff_datetime = timezone.now() - frequency
requests = (
requests = _exclude_inactive_staffbot_requests(
StaffBotRequest.objects
.filter(status__in=[
StaffBotRequest.Status.SENDING_INQUIRIES.value,
Expand Down Expand Up @@ -322,14 +331,9 @@ def get_available_requests(worker):
# winner or for which they have not already replied.
worker_provided_responses = StaffingResponse.objects.filter(
request_inquiry__communication_preference__worker=worker)
remaining_requests = (
remaining_requests = _exclude_inactive_staffbot_requests(
StaffBotRequest.objects
.filter(inquiries__communication_preference__worker=worker)
.exclude(status=StaffBotRequest.Status.CLOSED.value)
.exclude(task__project__status=Project.Status.COMPLETED)
.exclude(task__project__status=Project.Status.ABORTED)
.exclude(task__status=Task.Status.COMPLETE)
.exclude(task__status=Task.Status.ABORTED)
.exclude(inquiries__responses__in=worker_provided_responses)
.distinct())
inquiries = (
Expand Down

0 comments on commit 321a56c

Please sign in to comment.