       (f (first items)) idx
       :else (recur (inc idx) (rest items)))))
 
-(defn- migrate-follow-ups-for-entry [conn e self-only? dry-run?]
+(defn- migrate-follow-ups-for-entry [conn e self-only? dry-run? complete-follow-ups?]
   (let [follow-ups (:follow-ups e)
         new-bookmarks (remove nil? (mapv #(when (and (not (:completed? %))
                                            (or (not self-only?)

                                    (:assignee %))
                            follow-ups))
        updated-bookmarks (clojure.set/union (set (map :user-id new-bookmarks)) (:bookmarks e))
        updated-follow-ups (mapv #(if (and (not (:completed? %))
                                             (or (not self-only?)
                                                 (and self-only?
                                                      (= (-> % :assignee :user-id) (-> % :author :user-id)))))
                                      (assoc % :completed? true)
                                      %)
                              follow-ups)]
    (println "  Updating entry:" (:uuid e))
    (println "    Adding bookmarks for:" updated-bookmarks)
    (println "    Updating follow-ups:")
    (doseq [f updated-follow-ups]
      (println "     -" (:uuid f) "completed?" (:completed? f) "self?" (= (-> f :assignee :user-id) (-> f :author :user-id))))
    (when-not dry-run?
      (println "  Actually updating entry:" (:uuid e))
      (entry/update-entry-no-user! conn (:uuid e) (merge e {:follow-ups updated-follow-ups
                                                            :bookmarks updated-bookmarks})))))

(defn- exit [status msg]
  (println msg)

            (let [entries (entries-for-org conn (:uuid o))]
              (println "Org:" (:uuid o) "-" (:name o))
              (doseq [e entries]
                (migrate-follow-ups-for-entry conn e
                 (:self-only options)                 ; Only self created follow-ups
                 (not (:force-update options))        ; Make changes in DB, no dry-run
                 (and (:force-update options)         ; Complete the relative follow-up,
                      (:complete-follow-ups options)) ; use this to keep them to re-run the import
                 )))))
        (delete-temp-index conn)
        (exit 0 "\n")

        (catch Exception e
          (println e)
          (delete-temp-index conn)
          (exit 1 "Bookmark migration exception."))))))
