Skip to content

Commit

Permalink
#387 Allow skipping is now a namespace setting (#391)
Browse files Browse the repository at this point in the history
* #387 Allow skipping is now a namespace setting

* Change skipability to integer number that skipping decrements priority by

* Cover negative priority edge case
  • Loading branch information
hannah-martinez authored Jan 17, 2023
1 parent 39cb222 commit 20f0074
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions neuvue_project/workspace/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NamespaceAdmin(admin.ModelAdmin):
"number_of_tasks_users_can_self_assign",
"max_number_of_pending_tasks_per_user",
"track_selected_segments",
"decrement_priority"
]
},
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.7 on 2023-01-16 22:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workspace', '0016_forcedchoicebuttongroup_number_of_selected_segments_expected'),
]

operations = [
migrations.AddField(
model_name='namespace',
name='decrement_priority',
field=models.IntegerField(default=100, verbose_name='When skipped, decrement priority by'),
),
]
1 change: 1 addition & 0 deletions neuvue_project/workspace/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Namespace(models.Model):
number_of_tasks_users_can_self_assign = models.IntegerField(default=10)
max_number_of_pending_tasks_per_user = models.IntegerField(default=200)
track_selected_segments = models.BooleanField(default=False)
decrement_priority = models.IntegerField(default=100, verbose_name="When skipped, decrement priority by")

"""Pull From Push To Novice"""
novice_pull_from = models.CharField(
Expand Down
6 changes: 4 additions & 2 deletions neuvue_project/workspace/views/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get(self, request, namespace=None, **kwargs):
"seg_id": "",
"is_open": False,
"tasks_available": True,
"skipable": True,
"skipable": True if namespace_obj.decrement_priority > 0 else False,
"instructions": "",
"display_name": namespace_obj.display_name,
"submission_method": submission_method,
Expand Down Expand Up @@ -291,10 +291,12 @@ def post(self, request, *args, **kwargs):
metadata["skipped"] = 1

try:
new_priority = task_df["priority"] - namespace_obj.decrement_priority
if new_priority < 0: new_priority = 0
client.patch_task(
task_df["_id"],
duration=duration,
priority=task_df["priority"] - 100,
priority=new_priority,
status="pending",
metadata=metadata,
ng_state=ng_state,
Expand Down

0 comments on commit 20f0074

Please sign in to comment.