Skip to content

Commit 6554519

Browse files
committed
version-aware store-statements fn
1 parent c711a45 commit 6554519

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/com/yetanalytics/lrs/impl/memory.cljc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,17 @@
442442

443443
#_{:clj-kondo/ignore [:unused-private-var]}
444444
(defn- store-statements-sync
445-
[state statements attachments]
446-
(try (let [prepared-statements
445+
[ctx state statements attachments]
446+
(try (let [{version :com.yetanalytics.lrs/version} ctx
447+
prepared-statements
447448
(map
448449
(fn [s stamp]
449450
(ss/prepare-statement
450-
(assoc s "stored" stamp)))
451+
(assoc s
452+
"stored" stamp
453+
"version" (case version
454+
"1.0.3" "1.0.0"
455+
"2.0.0" "2.0.0"))))
451456
statements
452457
(timestamp/stamp-seq))]
453458
(swap! state
@@ -885,8 +890,8 @@
885890
(-get-about [_ _ _]
886891
(get-about state))
887892
`~p/StatementsResource
888-
(-store-statements [_ _ _ statements attachments]
889-
(store-statements-sync state statements attachments))
893+
(-store-statements [_ ctx _ statements attachments]
894+
(store-statements-sync ctx state statements attachments))
890895
(-get-statements [_ _ _ params ltags]
891896
(get-statements-sync state xapi-path-prefix params ltags))
892897
(-consistent-through [_ _ _]
@@ -920,8 +925,8 @@
920925
(-get-about-async [lrs _ auth-identity]
921926
(a/go (get-about state)))
922927
`~p/StatementsResourceAsync
923-
(-store-statements-async [lrs _ auth-identity stmts attachments]
924-
(a/go (store-statements-sync state stmts attachments)))
928+
(-store-statements-async [lrs ctx auth-identity stmts attachments]
929+
(a/go (store-statements-sync ctx state stmts attachments)))
925930
(-get-statements-async [_ _ _ params ltags]
926931
(get-statements-async state xapi-path-prefix params ltags))
927932
(-consistent-through-async [_ _ _]

0 commit comments

Comments
 (0)