Skip to content

Commit

Permalink
Cap events at 250
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Sep 9, 2024
1 parent 2eae423 commit af6fe96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/co/gaiwan/compass/db.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns co.gaiwan.compass.db
(:require
[clojure.walk :as walk]
[co.gaiwan.compass.db.migrations :as migrations]
[co.gaiwan.compass.db.schema :as schema]
[datomic.api :as d]
[integrant.core :as ig]
Expand All @@ -21,7 +20,7 @@
(let [conn (d/connect url)]
@(transact conn (concat (schema/schema-tx)
wagontrain/schema))
(wagontrain/migrate! conn (munge-to-db migrations/all))
(wagontrain/migrate! conn (munge-to-db @(requiring-resolve 'co.gaiwan.compass.db.migrations/all)))
conn))

(defmethod ig/halt-key! :compass/db [_ conn])
Expand Down
21 changes: 20 additions & 1 deletion src/co/gaiwan/compass/db/migrations.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns co.gaiwan.compass.db.migrations
(:require [co.gaiwan.compass.db.data :as data]))
(:require
[co.gaiwan.compass.db.data :as data]
[datomic.api :as d]))

(def all
[{:label :add-locations
Expand Down Expand Up @@ -28,4 +30,21 @@
{:db/ident :location.type/hal5
:location/name "Hal 5 - Workshop Zone"}
{:location/name "Hal 5 - Community Space"}]}

{:label :cap-capacity-fn
:tx-data
[{:db/ident :compass.fn/cap-capacity
:db/fn (d/function {:lang "clojure"
:params '[db cap]
:code '(for [sid (datomic.api/q '[:find [?e ...]
:in $ ?cap
:where
[?e :session/capacity ?c]
[(< ?cap ?c)]]
db cap)]
[:db/add sid :session/capacity cap])})}]}

{:label :cap-capacity-250
:tx-data
[[:compass.fn/cap-capacity 250]]}
])

0 comments on commit af6fe96

Please sign in to comment.