   [{:keys [algorithm]}]
   true)
 
-(defn x-y-in-scope?
+(defn source-data-available?
   [{:keys [x y]}]
   true)
 
 (defn change-results-exist?
   [{:keys [x y algorithm]}]
   true)
+
+(defn query-data
+  [{:keys [x y algorithm]}]
+  {:algorithm algorithm
+   :start  12343
+   :end    45673
+   :days   [443 441 322]
+   :reds   [1 2 3]
+   :blues  [1 2 3]
+   :greens [1 2 3]
+   :nirs   [1 2 3]
+   :swir1s [1 2 3]
+   :swir2s [1 2 3]
+   :whatever ["the" "results" "are"]})
+
+(defn run-tile
+  [{:keys [x y algorithm] :as data}]
+  (let [existing-ticket (snap-x-y-and-check-iwds data)]
+    (if (some? existing-ticket)
+      existing-ticket
+      (enter-new-ticket-and-return))))
 
 ;;; request handlers
 (defn get-changes

          body      (merge data valid? results? source? {:doquery doquery?
                                                         :runtile runtile?})]
      (cond
        doquery? {:status 202 
                  :body (merge body {:changes (run-the-query-and-return)})}
        runtile? {:status 202
                  :body (merge body {:ticket (run-the-tile-and-return)})}
        :else    {:status 202
                  :body body}))))


     :or {r false}} :params}]
  (let [data   {:x x :y y :algorithm a :refresh (boolean r)}
        alg?   (future (algorithm-available? data))
        valid? {:algorithm-available @alg?}])
  (if (not-every? true? (vals valid?))
    {:status 202 :body (merge data valid?)}
    (let [src?      (future (source-data-available? data))
