       (let [{:keys [db-before
                     db-after
                     tx-data]} (.take queue)]
-        ;; No figure out if we need to
-        ;; add/remove a scheduled job
-        ;; or update the cron job for some
-        (schedule-new scheduler db-before db-after)
-        (schedule-removed scheduler db-before db-after)
-        (schedule-updates scheduler db-before db-after)
-        (println "============================================")))))
+        (schedule-new scheduler db-conn db-before db-after)
+        (schedule-removed scheduler db-conn db-before db-after)
+        (schedule-updates scheduler db-conn db-before db-after)))))
 
 (defn -main [db-uri]
   (log/merge-config! {:level :info

                                        schedule))
        (do (log/info "Skipping scheduling for" domain))))))

(defn schedule-new [schduler db-before db-after]
  (let [new-domains (d/q '[:find [?new-domains ...]
                           :in $db-before $db-after
                           :where
                           [$db-after ?team :team/domain ?new-domains]
                           [(missing? $db-before ?team :team/domain)]]
                         db-before db-after)]
    (prn "New domains:" new-domains)))

(defn schedule-removed [scheduler db-before db-after]
  (let [removed-domains (d/q '[:find [?removed-domains ...]
                               :in $ $db-after
                               :where
                               [$ ?team :team/domain ?removed-domains]
                               [(missing? $db-after ?team :team/domain)]]
                             db-before db-after)]
    (prn "Removed domains:" removed-domains)))

(defn schedule-updates [scheduler db-before db-after]
  (let [updated-crons (d/q '[:find ?domain ?schedule-after
                             :in $db-before $db-after
                             :where

                             [$db-after  ?team :team/schedule ?schedule-after]
                             [(not= ?schedule-before ?schedule-after)]]
                           db-before db-after)]
    (when-not (empty? updated-crons)
      (log/info "Updated schedules" (pr-str updated-crons)))
    (doseq [[domain new-schedule] updated-crons]
      (log/info "Unscheduling" domain)
      (scheduler/delete-job scheduler (jobs/key (str "jobs." domain)))
      (if-not (empty? new-schedule)
        (do (log/infof "Scheduling domain %s with schedule %s" domain new-schedule)
            (schedule-questionnaire-job scheduler db-conn domain new-schedule))
        (do (log/info "Skipping scheduler for domain" domain))))))

(defn listen-for-team-updates [scheduler db-conn]
  (let [queue (d/tx-report-queue db-conn)]
