Skip to content

Commit 6cdb5d4

Browse files
committed
chore: repl hacks
1 parent 7ebc2d7 commit 6cdb5d4

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

repl/reactions.clj

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[clojurians-log.db.queries :as q]
66
[clojurians-log.db.import :as import]
77
[clojurians-log.data :as data]
8+
[clj-slack.emoji :as slack-emoji]
89
[clojure.java.io :as io]
910
[clojurians-log.datomic :as d]
1011
[clojure.tools.reader.edn :as edn]
@@ -15,10 +16,10 @@
1516

1617
(d/q '[:find (pull ?m [* {:reaction/_message [{:reaction/emoji [:emoji/shortcode :emoji/url]}]}])
1718
:where
18-
[?u :user/name "borkdude"]
19-
[?m :message/day "2018-02-08"]
19+
;; [?u :user/name "borkdude"]
20+
;; [?m :message/day "2018-02-08"]
2021
[?m :message/channel ?chan]
21-
[?chan :channel/name "aleph"]]
22+
[?chan :channel/name "announcements"]]
2223
(db))
2324

2425
(q/channel-day-messages (db) "aleph" "2018-02-08")
@@ -54,15 +55,30 @@
5455
(d/transact (conn) [{:emoji/shortcode "+1" :emoji/url "url1"}])
5556
(d/transact (conn) [{:emoji/shortcode "joy" :emoji/url "url1"}])
5657
(d/q '[:find (pull ?e [*]) :where [?e :emoji/shortcode]] (db))
58+
(d/q '[:find (pull ?e [*]) :where [?e :emoji/shortcode "sheepy"]] (db))
5759

5860
;; add default emojis
5961
(def default-emojis
6062
(with-open [r (io/reader (io/resource "emojis.json"))]
6163
(let [emoji-list (-> (json/read r :key-fn keyword) :emojis)]
6264
(map #(hash-map :emoji/shortcode (:name %)) emoji-list))))
65+
66+
(def emlist (with-open [r (io/reader (io/resource "emojis.json"))]
67+
(let [emoji-list (-> (json/read r :key-fn keyword))]
68+
emoji-list)))
69+
70+
71+
(into {} (map (comp first #(for [alias (:aliases %)] [alias (:emoji %)])) emlist))
72+
6373
(d/transact (conn) default-emojis)
6474
(d/q '[:find (pull ?e [*]) :where [?e :emoji/shortcode]] (db))
6575

76+
(def emcoll (slack-emoji/list {:api-url "https://slack.com/api"
77+
;; TODO: get rid of this global config access
78+
:token ""}))
79+
80+
(doseq [emojis (partition-all 1000 (:emoji emcoll))]
81+
@(d/transact (conn) (mapv import/emoji->tx emojis)))
6682

6783
(load-demo-data! "../clojurians-log-demo-data2")
6884
)
@@ -83,6 +99,11 @@
8399
:reaction/emoji [:emoji/shortcode "+1"]
84100
:reaction/ts "1001"
85101
:reaction/user [:user/name "plexus"]
86-
:reaction/message [:message/key "C0G922PCH--1518108773.000057"]}]))
102+
:reaction/message [:message/key "C0G922PCH--1518108773.000057"]}])
103+
104+
(d/q '[:find (pull ?m [*])
105+
:where
106+
[?m :message/key "C0G922PCH--1518108773.000057"]]
107+
(db)))
87108

88109

0 commit comments

Comments
 (0)