   (:require [clj-http.client :as client])
   (:require [clojure.data.json :as json])
   (:require [environ.core :as e])
+  (:require [clj-time.core :as t])
+  (:require [clj-time.coerce :as c])
   (:require [clojurewerkz.neocons.rest :as nr]
             [clojurewerkz.neocons.rest.transaction :as tx]))
 

                    MERGE (m:MeetupProfile {id: {person}.id})
                    SET m = {person}
                    MERGE (p)-[:HAS_MEETUP_PROFILE]->(m)
                    FOREACH(topic IN {topics} |
                      MERGE (t:Topic {id: topic.id})
                      SET t = topic

(defn responses [rsvp]
  (if (changed-mind? rsvp)
    (if (= "yes" (:response rsvp))
      [{:response (:response rsvp)
        :time (:created rsvp)
        :timetree (as-timetree (:created rsvp))
        :guests (:guests rsvp)}]
      [{:response "yes"
        :time (:created rsvp)
        :timetree (as-timetree (:created rsvp))
        :guests (:guests rsvp)}
       {:response (:response rsvp)
        :time (:mtime rsvp)
        :timetree (as-timetree (:mtime rsvp))
        :guests 0}])
    [{:response (:response rsvp)
      :time (:created rsvp)
      :timetree (as-timetree (:created rsvp))      
      :guests (:guests rsvp)}]))

(defn rsvps-with-responses [rsvps]
  (map #(assoc % :responses (responses %)) rsvps))
