           (println "Users" users)
           (println "Questions" questions)))))
 
-(defn schedule-questionnaire-job [scheduler domain cron-string]
+(defn schedule-questionnaire-job [scheduler db-conn domain cron-string]
   (let [job (jobs/build
              (jobs/of-type QuestionnaireJob)
-             (jobs/using-job-data {:domain domain})
+             (jobs/using-job-data {:domain domain
+                                   :db-conn db-conn})
              (jobs/with-identity (jobs/key (str "jobs." domain))))
         trigger (triggers/build
                  (triggers/with-identity (triggers/key (str "triggers." domain)))


(defn -main [db-uri]
  (let [scheduler (scheduler/start (scheduler/initialize))
        db-conn (d/connect db-uri)
        db (d/db db-conn)]
    (init-start-jobs scheduler db)
    (listen-for-team-updates scheduler db-conn)))

(comment

                    (cron/cron-schedule cron-string))))]
    (scheduler/schedule scheduler job trigger)))

(defn init-start-jobs [scheduler db-conn]
  (doseq [db (d/db db-conn)
          {:keys [domain schedule]} (d/q '[:find (pull ?team [:team/domain :team/schedule])
                                           :where
                                           [?team :team/domain]]
                                         db)]
    (schedule-questionnaire-job scheduler
                                db-conn
                                domain
                                schedule)))

