From e6f43e2a98978a1b2d718b1eb1c13c8ff3b5ef0d Mon Sep 17 00:00:00 2001
From: Allen Gilliland <agilliland@gmail.com>
Date: Wed, 23 Mar 2016 09:15:08 -0700
Subject: [PATCH] style tweaks.

---
 src/metabase/db/migrations.clj | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/metabase/db/migrations.clj b/src/metabase/db/migrations.clj
index 7235c251066..085dab61b1a 100644
--- a/src/metabase/db/migrations.clj
+++ b/src/metabase/db/migrations.clj
@@ -154,19 +154,19 @@
 
 ;; deal with dashboard cards which have NULL `:row` or `:col` values
 (defmigration fix-dashboard-cards-without-positions
-  (let [bad-dashboards (k/select DashboardCard (k/fields [:dashboard_id]) (k/modifier "DISTINCT") (k/where (or (= :row nil) (= :col nil))))]
-    (when (not-empty bad-dashboards)
-      (log/info "Looks like we need to fix unpositioned cards in these dashboards:" (mapv :dashboard_id bad-dashboards))
-      ;; we are going to take the easy way out, which is to put bad-cards at the bottom of the dashboard
-      (doseq [{dash-to-fix :dashboard_id} bad-dashboards]
-        (let [max-row   (or (:row (first (k/select DashboardCard (k/aggregate (max :row) :row) (k/where {:dashboard_id dash-to-fix})))) 0)
-              max-size  (or (:size (first (k/select DashboardCard (k/aggregate (max :sizeY) :size) (k/where {:dashboard_id dash-to-fix, :row max-row})))) 0)
-              max-y     (+ max-row max-size)
-              bad-cards (k/select DashboardCard (k/fields :id :sizeY) (k/where {:dashboard_id dash-to-fix}) (k/where (or (= :row nil) (= :col nil))))]
-          (loop [[bad-card & rest] bad-cards
-                 row-target        max-y]
-            (k/update DashboardCard
-              (k/set-fields {:row row-target
-                             :col 0})
-              (k/where      {:id  (:id bad-card)}))
-            (when rest (recur rest (+ row-target (:sizeY bad-card))))))))))
+  (when-let [bad-dashboards (not-empty (k/select DashboardCard (k/fields [:dashboard_id]) (k/modifier "DISTINCT") (k/where (or (= :row nil) (= :col nil)))))]
+    (log/info "Looks like we need to fix unpositioned cards in these dashboards:" (mapv :dashboard_id bad-dashboards))
+    ;; we are going to take the easy way out, which is to put bad-cards at the bottom of the dashboard
+    (doseq [{dash-to-fix :dashboard_id} bad-dashboards]
+      (let [max-row   (or (:row (first (k/select DashboardCard (k/aggregate (max :row) :row) (k/where {:dashboard_id dash-to-fix})))) 0)
+            max-size  (or (:size (first (k/select DashboardCard (k/aggregate (max :sizeY) :size) (k/where {:dashboard_id dash-to-fix, :row max-row})))) 0)
+            max-y     (+ max-row max-size)
+            bad-cards (k/select DashboardCard (k/fields :id :sizeY) (k/where {:dashboard_id dash-to-fix}) (k/where (or (= :row nil) (= :col nil))))]
+        (loop [[bad-card & more] bad-cards
+               row-target        max-y]
+          (k/update DashboardCard
+            (k/set-fields {:row row-target
+                           :col 0})
+            (k/where      {:id  (:id bad-card)}))
+          (when more
+            (recur more (+ row-target (:sizeY bad-card)))))))))
-- 
GitLab