Skip to content

Commit 65b109c

Browse files
committed
feat: random ad-hoc repl commands related to reactions
1 parent 9d9f4b1 commit 65b109c

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

repl/reactions.clj

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
(ns repl.reactions
2+
(:require [clojurians-log.application :as app]
3+
[clojure.java.io :as io]
4+
[clojurians-log.slack-api :as slack]
5+
[clojurians-log.db.queries :as q]
6+
[clojurians-log.db.import :as import]
7+
[clojurians-log.data :as data]
8+
[clojure.java.io :as io]
9+
[clojurians-log.datomic :as d]
10+
[clojure.tools.reader.edn :as edn]
11+
[clojure.string :as str]
12+
[clojure.core.async :as async :refer [>!! <! >! go-loop go <!!]]
13+
[clojure.data.json :as json])
14+
(:use [clojurians-log.repl]))
15+
16+
(d/q '[:find (pull ?m [* {:reaction/_message [{:reaction/emoji [:emoji/shortcode :emoji/url]}]}])
17+
:where
18+
[?u :user/name "borkdude"]
19+
[?m :message/day "2018-02-08"]
20+
[?m :message/channel ?chan]
21+
[?chan :channel/name "aleph"]]
22+
(db))
23+
24+
(q/channel-day-messages (db) "aleph" "2018-02-08")
25+
26+
(d/q '[:find (pull ?r [*]) (pull ?m [*])
27+
:where
28+
[?u :user/name "borkdude"]
29+
[?m :message/day "2018-02-08"]
30+
[?m :message/channel ?chan]
31+
[?chan :channel/name "aleph"]
32+
[?r :reaction/message ?m]]
33+
(db))
34+
35+
(d/q '[:find ?m ?r
36+
:where
37+
[?r :reaction/message ?m]]
38+
(db))
39+
40+
(d/q '[:find (pull ?r [*])
41+
:where
42+
[?r :reaction/type]]
43+
(db))
44+
45+
;; find a message by key
46+
(d/q '[:find (pull ?m [*])
47+
:where
48+
[?m :message/key "C0E1SN0NM--1604347443.149900"]]
49+
(db))
50+
51+
52+
(comment
53+
;; add some emojis
54+
(d/transact (conn) [{:emoji/shortcode "+1" :emoji/url "url1"}])
55+
(d/transact (conn) [{:emoji/shortcode "joy" :emoji/url "url1"}])
56+
(d/q '[:find (pull ?e [*]) :where [?e :emoji/shortcode]] (db))
57+
58+
;; add default emojis
59+
(def default-emojis
60+
(with-open [r (io/reader (io/resource "emojis.json"))]
61+
(let [emoji-list (-> (json/read r :key-fn keyword) :emojis)]
62+
(map #(hash-map :emoji/shortcode (:name %)) emoji-list))))
63+
(d/transact (conn) default-emojis)
64+
(d/q '[:find (pull ?e [*]) :where [?e :emoji/shortcode]] (db))
65+
66+
67+
(load-demo-data! "../clojurians-log-demo-data2")
68+
)
69+
70+
(comment
71+
(d/q '[:find ?eid :in $ ?eid :where [?eid]] (db) 17592186091857))
72+
73+
(comment
74+
(d/transact (conn) [{:db/id 17592186091852 :emoji/shortcode "joy" :emoji/url "url1"}])
75+
76+
(d/transact (conn) [{:db/ident :emoji/shortcode
77+
:db/index true}])
78+
79+
(d/transact (conn) [{:db/ident :emoji/shortcode
80+
:db/unique :db.unique/identity}])
81+
82+
(d/transact (conn) [{:reaction/type "reaction_added"
83+
:reaction/emoji [:emoji/shortcode "+1"]
84+
:reaction/ts "1001"
85+
:reaction/user [:user/name "plexus"]
86+
:reaction/message [:message/key "C0G922PCH--1518108773.000057"]}]))
87+
88+

0 commit comments

Comments
 (0)