                  [?u :user/preferences ?p]
                  [?p :user.preference/key ?key]
                  [?p :user.preference/value ?val]]
-               (d/db *conn*) user-id pref)
+               (d/db conn) user-id pref)
           edn/read-string))
 
 (defn user-preference-is-set?
   "If the preference with the given key has been set for the user, return the
   entity id, else nil"
-  [user-id pref]
+  [conn user-id pref]
   (d/q '[:find ?p .
          :in $ ?user-id ?key
          :where
          [?u :user/id ?user-id]
          [?u :user/preferences ?p]
          [?p :user.preference/key ?key]]
-       (d/db *conn*) user-id pref))
+       (d/db conn) user-id pref))
 
 (defn user-set-preference!
   "Set a key to a value for the user's preferences.  This will throw if
   permissions are changed in between reading & setting"
-  [user-id k v]
+  [conn user-id k v]
   (if-let [e (user-preference-is-set? user-id k)]
-    @(d/transact *conn* [[:db/add e :user.preference/value (pr-str v)]])
-    @(d/transact *conn* [{:user.preference/key k
+    @(d/transact conn [[:db/add e :user.preference/value (pr-str v)]])
+    @(d/transact conn [{:user.preference/key k
                          :user.preference/value (pr-str v)
                          :user/_preferences [:user/id user-id]
                          :db/id #db/id [:entities]}])))
 
 (defn user-search-preferences
   "Find the ids of users that have the a given value for a given key set in their preferences"
-  [k v]
+  [conn k v]
   (d/q '[:find [?user-id ...]
          :in $ ?k ?v
          :where

      db->invitation))

(defn get-invite
  [invite-id]
  (some-> (d/pull (d/db *conn*)
              [:invite/id
               {:invite/from [:user/id :user/email :user/nickname]}
               :invite/to

                [?u :user/id ?user-id]
                [?g :group/user ?u]
                [?t :tag/group ?g]]
              (d/db conn) user-id)
         (map (fn [[tag]]
                (db->tag (merge tag (tag-stats (tag :tag/id))))))
         (into #{}))))
