# now we know we have a due date. for every day that passes,
# increment priority according to the formula
# now we know we have a due date. for every day that passes,
# increment priority according to the formula
$due = $starts + 1 if $due <= $starts; # +1 to avoid div by zero
my $percent_complete = ($now-$starts)/($due - $starts);
my $new_priority = int($percent_complete * $priority_range) + ($ticket->InitialPriority || 0);
$due = $starts + 1 if $due <= $starts; # +1 to avoid div by zero
my $percent_complete = ($now-$starts)/($due - $starts);
my $new_priority = int($percent_complete * $priority_range) + ($ticket->InitialPriority || 0);