diff options
author | Tom Willemse | 2013-08-18 23:19:25 +0200 |
---|---|---|
committer | Tom Willemse | 2013-08-18 23:19:25 +0200 |
commit | bb2f75ec1ccb662e1a71a8e4f23fe3dcfbf8bafe (patch) | |
tree | a6682d8490044d6f9d2db1c613654e2ccdc693bc /data.lisp | |
parent | 321d6b199fffd863517731cf27b4f11e0d6bcb9b (diff) | |
download | scrumli-bb2f75ec1ccb662e1a71a8e4f23fe3dcfbf8bafe.tar.gz scrumli-bb2f75ec1ccb662e1a71a8e4f23fe3dcfbf8bafe.zip |
When selecting the task to replace the task with based on priority, be
sure to limit the options to tasks with the same story id.
Diffstat (limited to 'data.lisp')
-rw-r--r-- | data.lisp | 37 |
1 files changed, 22 insertions, 15 deletions
@@ -98,30 +98,37 @@ (defun story-set-state (type id state) (execute (:update type :set 'state state :where (:= 'id id)))) -(defun story-change-priority (type id dir) - (let* ((current-priority (query (:select 'priority :from type +(defun story-change-priority (id dir) + (let* ((current-priority (query (:select 'priority :from 'story :where (:= 'id id)) :single)) (next-priority (funcall (ecase dir (:up #'-) (:down #'+)) current-priority 1)) (max-priority - (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 + (query (:select (:max 'priority) :from 'story) + :single))) + (execute (:update 'story :set 'priority current-priority :where (:= 'priority next-priority))) - (execute (:update type :set + (execute (:update 'story :set 'priority (max 1 (min next-priority max-priority)) :where (:= 'id id))))) +(defun task-change-priority (id dir) + (destructuring-bind (priority story-id) + (query (:select 'priority 'story-id :from 'task + :where (:= 'id id)) :list) + (let* ((next-priority + (funcall (ecase dir (:up #'-) (:down #'+)) priority 1)) + (max-priority + (query (:select (:max 'priority) :from 'task + :where (:= 'story-id story-id)) :single))) + (execute (:update 'task :set 'priority priority + :where (:and (:= 'priority next-priority) + (:= 'story-id story-id)))) + (execute (:update 'task :set + 'priority (max 1 (min next-priority max-priority)) + :where (:= 'id id)))))) + (defun set-assignee (type id assignee) (execute (:update type :set 'assignee assignee :where (:= 'id id)))) |