Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit 6307770

Browse files
committed
wip: augment service
1 parent fcad308 commit 6307770

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

functions/src/app/augment/mappings.cljs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@
22
(:require [backend-shared.service.index :refer [perform fetch]]
33
[shared.protocols.actionable :as ac]
44
[shared.protocols.queryable :as qa]
5-
[shared.protocols.loggable :as log])
5+
[shared.protocols.loggable :as log]
6+
[cljs.core.async :as async]
7+
[clojure.string :as str])
68
(:require-macros [cljs.core.async.macros :refer [go]]))
79

810
(defn mappings []
911

12+
(defn to-course-query [{:keys [offcourse-id]}]
13+
(let [[repo curator course-id revision checkpoint-id] (str/split offcourse-id "::")]
14+
{:course-id (str repo "::" curator "::" course-id)
15+
:checkpoint-id checkpoint-id
16+
:revision revision}))
17+
1018
(defmethod fetch :bookmarks [{:keys [db]} payload]
11-
(let [query (map (fn [{:keys [bookmark-url]}] {:resource-url bookmark-url}) payload)]
12-
(qa/fetch db query)))
19+
(go
20+
(let [bookmarks-query (map (fn [{:keys [bookmark-url]}] {:resource-url bookmark-url}) payload)
21+
{:keys [found]} (async/<! (qa/fetch db bookmarks-query))
22+
courses-query (map to-course-query found)
23+
{:keys [found]} (async/<! (qa/fetch db courses-query))]
24+
found)))
1325

1426
(defmethod perform [:put :nothing] [_ _]
1527
(go {:error :no-payload}))

0 commit comments

Comments
 (0)