 (defn- tree-attachment-public-viewable? [request]
   (let [tree-id (-> request :route-params :tree_id)
         query (-> (build-basequery) 
-                  (hh/merge-where [:= :executions.tree_id tree-id])
+                  (hh/merge-where [:= :jobs.tree_id tree-id])
                   hc/format)
         qres (first (jdbc/query (rdbms/get-ds) query)) ]
     ; this is not used as a http response


(defn- build-basequery []
  (-> (hh/select :true)
      (hh/from :executions)
      (hh/merge-join :commits [:= :commits.tree_id :executions.tree_id])
      (hh/merge-join :branches_commits [:= :branches_commits.commit_id :commits.id])
      (hh/merge-join :branches [:= :branches.id :branches_commits.branch_id])
      (hh/merge-join :repositories [:= :repositories.id :branches.repository_id])

  (let [trial-id (-> request :route-params :trial_id 
                     rdbms.conversion/convert-to-uuid)
        query (-> (build-basequery) 
                  (hh/merge-join :tasks [:= :tasks.job_id :jobs.id])
                  (hh/merge-join :trials [:= :trials.task_id :tasks.id])
                  (hh/merge-where [:= :trials.id trial-id])
                  hc/format)
