This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-08
Channels
- # adventofcode (31)
- # beginners (97)
- # bigdata (2)
- # boot (276)
- # cider (17)
- # cljsrn (5)
- # clojure (150)
- # clojure-china (3)
- # clojure-conj (8)
- # clojure-greece (1)
- # clojure-india (1)
- # clojure-korea (1)
- # clojure-new-zealand (4)
- # clojure-russia (40)
- # clojure-spec (119)
- # clojure-uk (116)
- # clojurescript (87)
- # code-reviews (110)
- # core-async (4)
- # cursive (11)
- # datomic (26)
- # garden (4)
- # gorilla (7)
- # hoplon (82)
- # humor (1)
- # jobs (2)
- # jobs-discuss (10)
- # luminus (17)
- # onyx (60)
- # planck (2)
- # play-clj (2)
- # protorepl (70)
- # re-frame (121)
- # reagent (7)
- # ring-swagger (3)
- # rum (16)
- # test-check (16)
- # untangled (12)
- # yada (20)
here a url where you can see the site in action : https://lit-lowlands-46138.herokuapp.com/
I like to pull down repos and run them locally but it looks like I can't since I need an api key. First thing I suggest is to update the readme with the purpose, if you can run it locally, design decisions you made, etc.
@roelofw you can pass a :query-params
map instead of building the query-string manually e..g here https://github.com/rwobben/paintings/blob/master/src/clj/paintings2/api_get.clj#L39
you can drop everything after the '?' and put it in a map like {:format "json" :key apikey}
so it will be (client/get {:as :json :format "json" :key (env :key})
as I understand your right ?
not quite (client/get (str "
the rest is pretty good for a first project. I'd look into your editor and find a way to auto-format removing extra spaces and trailing parens
@roelofw you might also want to look at http-kit over clj-http http://stackoverflow.com/a/21473485 depends how many ids
you're doing in parallel.
@snoe : can you see if I made a error here :
( str "")
(client/get {:as :json :query-params {:key (env :key) :format "json" :type "schilderijen" :toppieces "True"}})
@snoe : you mean like this : (client/get {:as :json :query-params {:key (env :key) :format "json" "type=schilderijen" :toppieces "True"}})
sounds like you got it, but I did notice this last pmap
should probably be a map
https://github.com/rwobben/paintings/blob/master/src/clj/paintings2/api_get.clj#L54 because merge
is so fast
and here the changed code with your name mentioned : https://github.com/rwobben/paintings
https://github.com/rwobben/paintings/blob/master/src/clj/paintings2/api_get.clj#L15 this reduce
looks like a map
to me using https://clojuredocs.org/clojure.core/subs
you can do almost anything to a list with reduce
, map
filter
etc are just a level of abstraction above. especially when learning clojure if you ever feel the need to use reduce
first look through clojure.core
for a function that fits what you want to do more closely
in read-numbers, how are you able to use the :artObjects
key when the body is a json string?
I also noticed in the json response that there is a key called "objectNumber" that is exactly what you're trying to get when you substring the id
can be map-id looks like this:
("nl-SK-A-2963"
"nl-SK-C-2"
"nl-SK-C-149"
"nl-SK-A-3841"
"nl-SK-C-1368"
"nl-SK-A-1718"
"nl-SK-A-1115"
"nl-SK-A-799"
"nl-SK-A-3584"
"nl-SK-A-2860")
at the repl you get json. I was pulling out the object numbers with
(re-seq #"SK-[A-Z]-[0-9]{0, 4}" body-of-response)
json respons from this
( str "")
(client/get {:as :json :query-params {:key (env :key) :format "json" :type "schilderij" :toppieces "True"}})
also, I'm running a bare repl with only clj-http as a dep, I'm not running it from the project
okay, I see where you're concating the id. wow the codebase keeps mutating out from under me lol
@gdeer81 this better :
(defn read-numbers
"Reads the ids of the paintings"
[]
(let [data (-> (client/get "" {:as :json :query-params {:key (env :key) :format "json" :type "schilderij" :toppieces "True"}})
:body
:artObjects
)
map-id (map :id data)
ids (map (fn [item] (subs item 3 )) map-id) ]
ids ))
@hiredman thank you. Okay I spun up my repl with lein try "clj-http" "cheshire"
and it gave me enough dependencies to test the function
@roelofw Spoiler alert, you can do all of that with (->> (client/get "