aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-07-15 22:01:36 +0200
committerGravatar Tom Willemse2013-07-15 22:01:36 +0200
commitcfab0475f33233a4d36d729e8cf6e34edd45d0aa (patch)
tree224cd7737079ac34502a41b1f09a2221e9ac8262
parent86b448369e155b98c0659c3e360f62f70a1cca97 (diff)
downloadscrumli-cfab0475f33233a4d36d729e8cf6e34edd45d0aa.tar.gz
scrumli-cfab0475f33233a4d36d729e8cf6e34edd45d0aa.zip
Keep priorities from diverging
Priorities should always be a sequence...
-rw-r--r--pg-datastore.lisp7
1 files changed, 5 insertions, 2 deletions
diff --git a/pg-datastore.lisp b/pg-datastore.lisp
index 805e748..260902e 100644
--- a/pg-datastore.lisp
+++ b/pg-datastore.lisp
@@ -94,8 +94,11 @@
:where (:= 'id id))
:single))
(next-priority (funcall (ecase dir (:up #'-) (:down #'+))
- current-priority 1)))
+ current-priority 1))
+ (max-priority (query (:select (:max 'priority) :from type)
+ :single)))
(execute (:update type :set 'priority current-priority
:where (:= 'priority next-priority)))
- (execute (:update type :set 'priority next-priority
+ (execute (:update type :set
+ 'priority (max 1 (min next-priority max-priority))
:where (:= 'id id))))))