 ;##############################################################################
 
 (defn next-trial-for-pull [tx executor]
-  (->> (-> trials-excutors-query-ordered
+  (->> (-> (trials-excutors-query-ordered)
            (sql-merge-where [:= :exs.id (:id executor)])
            (sql-merge-where [:= cider-ci.self/VERSION (:version executor)])
            (sql-limit 1) sql-format)

      (sql-merge-where (sql-raw (str "(exs.last_ping_at >  "
                                     "(now() - interval '1 Minutes'))")))
      (sql-merge-where without-conflicting-dispatch-storm-delay)
      (sql-merge-where without-or-with-available-global-resource-condition)))

(def ^:private trials-excutors-base-with-repo
  (-> trials-excutors-base-query
      (sql-merge-join :jobs [:= :tasks.job_id :jobs.id])
      (sql-merge-join :commits [:= :jobs.tree_id :commits.tree_id])
      (sql-merge-join [:branches_commits :bcts]

    [cider-ci.utils.rdbms :as rdbms]
    [clojure.java.jdbc :as jdbc]
    [honeysql.sql :refer :all]
    [cider-ci.utils.config :as config :refer [get-config]]

    [clj-logging-config.log4j :as logging-config]
    [clojure.tools.logging :as logging]
