Fix priorities for tasks

When setting and changing priorities no attention was paid to the
`story_id', which means that no two tasks could have the same priority,
even when belonging to other stories. This creates a weird situation
where the tasks of a certain story would become unmanageable because
there are gaps between the priorities. This could make it seem like
priority changing was impossible.
This commit is contained in:
Tom Willemse 2013-08-18 16:55:56 +02:00
parent 6e5b291257
commit aa06a99982

View file

@ -85,7 +85,9 @@
'task :description description 'task :description description
:priority (+ 1 (query (:select :priority (+ 1 (query (:select
(:coalesce (:max 'priority) 0) (:coalesce (:max 'priority) 0)
:from 'task) :single)) :from 'task
:where (:= 'story-id story-id))
:single))
:reporter reporter :story-id (parse-integer story-id) :reporter reporter :story-id (parse-integer story-id)
:assignee ""))) :assignee "")))
(save-dao obj))) (save-dao obj)))
@ -102,8 +104,18 @@
:single)) :single))
(next-priority (funcall (ecase dir (:up #'-) (:down #'+)) (next-priority (funcall (ecase dir (:up #'-) (:down #'+))
current-priority 1)) current-priority 1))
(max-priority (query (:select (:max 'priority) :from type) (max-priority
:single))) (case type
('story (query (:select (:max 'priority) :from type)
:single))
('task
(query (:select
(:max 'priority) :from type
:where (:= 'story-id
(:select 'story-id
:from 'task
:where (:= 'id id))))
:single)))))
(execute (:update type :set 'priority current-priority (execute (:update type :set 'priority current-priority
:where (:= 'priority next-priority))) :where (:= 'priority next-priority)))
(execute (:update type :set (execute (:update type :set