 (defn mongo-connect! [mongo-url]
   (monger.core/connect-via-uri! mongo-url))
 
+
 (defn mongo-upsert-results [zid timestamp new-results ]
   (monger.collection/update "polismath_test1248124"
     {

    }
    :multi false
    :upsert true))


; (defn post-results [db-spec zid last-timestamp results-json]
;   (kdb/with-db db-spec
;     (ko/update "math_results_dev01"
;       (ko/set-fields {
;         :data results-json
;         :last_timestamp last-timestamp })
;       (ko/where {
;         :zid [= zid]
;         :last_timestamp [< last-timestamp] }))))

; (defn post-results-raw [db-spec zid last-timestamp results-json]
;   (kdb/with-db db-spec
;     (ko/exec-raw [
;       "UPDATE math_results_dev01 SET data = ?, last_timestamp = ? WHERE zid = ? RETURNING zid"
;       [results-json last-timestamp zid]
;       :results])))


; (defn post-results-insert [db-spec zid last-timestamp results-json]
;   (kdb/with-db db-spec
;     (ko/insert "math_results_dev01"
;       (ko/values {
;         :data results-json
;         :last_timestamp last-timestamp
;         :zid zid}))))

; (defn upsert-results [db-spec zid last-timestamp results-json]
;   (try
;     (post-results-insert db-spec 1001 0 results-json)
;     (catch Exception e
;       (post-results db-spec 1001 1 results-json))))


(defn poll [db-spec last-timestamp]

                      (conv-update (or (convs zid) {:rating-mat (named-matrix)}) votes)
                      (catch Exception e (println "exception when processing zid: " zid))))))
                
            (println "zid: " zid)
            (println "time: " (System/currentTimeMillis))
            (println "\n\n")
            (println (generate-string (prep-for-uploading (@conversations zid))))
            (println 
              (mongo-upsert-results
                zid
