Really fix setting priority for tasks
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.
This commit is contained in:
parent
321d6b199f
commit
bb2f75ec1c
2 changed files with 26 additions and 20 deletions
37
data.lisp
37
data.lisp
|
@ -98,30 +98,37 @@
|
||||||
(defun story-set-state (type id state)
|
(defun story-set-state (type id state)
|
||||||
(execute (:update type :set 'state state :where (:= 'id id))))
|
(execute (:update type :set 'state state :where (:= 'id id))))
|
||||||
|
|
||||||
(defun story-change-priority (type id dir)
|
(defun story-change-priority (id dir)
|
||||||
(let* ((current-priority (query (:select 'priority :from type
|
(let* ((current-priority (query (:select 'priority :from 'story
|
||||||
:where (:= 'id id))
|
:where (:= 'id id))
|
||||||
:single))
|
:single))
|
||||||
(next-priority (funcall (ecase dir (:up #'-) (:down #'+))
|
(next-priority (funcall (ecase dir (:up #'-) (:down #'+))
|
||||||
current-priority 1))
|
current-priority 1))
|
||||||
(max-priority
|
(max-priority
|
||||||
(case type
|
(query (:select (:max 'priority) :from 'story)
|
||||||
('story (query (:select (:max 'priority) :from type)
|
:single)))
|
||||||
:single))
|
(execute (:update 'story :set 'priority current-priority
|
||||||
('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
|
|
||||||
:where (:= 'priority next-priority)))
|
:where (:= 'priority next-priority)))
|
||||||
(execute (:update type :set
|
(execute (:update 'story :set
|
||||||
'priority (max 1 (min next-priority max-priority))
|
'priority (max 1 (min next-priority max-priority))
|
||||||
:where (:= 'id id)))))
|
: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)
|
(defun set-assignee (type id assignee)
|
||||||
(execute (:update type :set 'assignee assignee
|
(execute (:update type :set 'assignee assignee
|
||||||
:where (:= 'id id))))
|
:where (:= 'id id))))
|
||||||
|
|
|
@ -208,17 +208,16 @@
|
||||||
(if (logged-in-p)
|
(if (logged-in-p)
|
||||||
(let ((id (getf params :|id|))
|
(let ((id (getf params :|id|))
|
||||||
(dir (getf params :dir)))
|
(dir (getf params :dir)))
|
||||||
(story-change-priority
|
(story-change-priority id (intern (string-upcase dir) :keyword))
|
||||||
'story id (intern (string-upcase dir) :keyword))
|
|
||||||
(list 200 '(:content-type "text/json")
|
(list 200 '(:content-type "text/json")
|
||||||
(encode-json-to-string '((status . "ok")))))
|
(encode-json-to-string '((status . "ok")))))
|
||||||
'(403)))
|
'(403)))
|
||||||
|
|
||||||
(defun task-move-json/post (params)
|
(defun task-move-json/post (params)
|
||||||
(if (logged-in-p)
|
(if (logged-in-p)
|
||||||
(let ((id (getf params :|id|)))
|
(let ((id (getf params :|id|))
|
||||||
(story-change-priority
|
(dir (getf params :dir)))
|
||||||
'task id (intern (string-upcase (getf params :dir)) :keyword))
|
(task-change-priority id (intern (string-upcase dir) :keyword))
|
||||||
(list 200 '(:content-type "text/json")
|
(list 200 '(:content-type "text/json")
|
||||||
(encode-json-to-string '((status . "ok")))))
|
(encode-json-to-string '((status . "ok")))))
|
||||||
'(403)))
|
'(403)))
|
||||||
|
|
Loading…
Reference in a new issue