Ah ... client/get is part of the standard httpclient library so it's not my code - it fetches from a url. Sorry I should have included the libraries that I used.
On Tuesday, May 28, 2013 10:33:52 PM UTC+2, nchurch wrote: > > Could you include the code in client/get? Not sure where that comes > from and it would be helpful to run the code to see what happens----no > guarantees though =) > > On May 28, 1:05 pm, Mond Ray <mondraym...@gmail.com> wrote: > > Quite a few views but no bites ... what have I done wrong in asking this > > question? If you can't help with the problem would you please take a > moment > > to help me understand what has put you off? > > > > Too much code not enough data? > > > > Problem too complex to grasp with the supplied info? > > > > Too dull? > > > > Am I asking too much ... in other words I have got this far and I should > be > > expected to know the answer (I really feel like I should too by the > way!) > > > > Use of the term Clojurians? > > > > Something else? > > > > Thanks > > > > Ray > > > > > > > > > > > > > > > > On Tuesday, 28 May 2013 13:44:57 UTC+2, Mond Ray wrote: > > > > > Hi Clojurians, > > > > > I have a program which generates a lazy sequence to read ATOM feed > chunks. > > > That part works OK but now I want to only take a limited number of the > > > chunks based on some predicate. My predicate is currently returning an > > > empty list so I think (hope!) I am missing something simple. > > > > > Here is an excerpt from the feed (yes the feed is in JSON and I have > used > > > cheshire to map to Clojure data): > > > > > {:FEED_ID "5650f3ad-b793-42c6-9fef-80ba105f847d", :TITLE "Delta Feed", > > > :UPDATED "2013-05-28T11:15:34.860+02:00", :GENERATOR "Products", :LINK > > > {:REL "Self", :HREF "http://some-url"}, :PREVIOUS_LINK {:REL > > > "prev-archive", :HREF "http://another-url"}, ..... > > > > > Here is the sequence generator: > > > > > (defn fetch-atom-chunk > > > "Returns an ATOM chunk from the feed-url" > > > [feed-url] > > > (:ATOM_FEED (:body (client/get feed-url {:as :json})))) > > > > > (defn fetch-atom-feed > > > "Returns a list of ATOM chunks from the feed-url going back to the > > > from-date" > > > ; [feed-url from-date] (fetch-atom-feed feed-url from-date ()) > > > [feed-url] > > > (let [chunk (fetch-atom-chunk feed-url)] > > > (lazy-seq > > > (cons chunk (fetch-atom-feed (:HREF (:PREVIOUS_LINK chunk))))))) > > > > > Here is the predicate: > > > > > (defn feed-date-to-clj-date > > > "Patch for ATOM feed date formats like > '2013-05-27T14:35:00.982+02:00' > > > we have to remove the final ':' from the string to enable its > > > conversion" > > > [feed-date] > > > (.parse (java.text.SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSSZ") > > > (str/replace feed-date #"(.*)(\d\d):(\d\d)" "$1$2$3"))) > > > > > (defn after? > > > "Returns true if first-date is after second-date" > > > [first-date second-date] > > > (> (.getTime first-date) (.getTime second-date))) > > > > > (defn more-feed-chunks-needed? > > > "Look at the atom chunk and decide if we have enough" > > > [from-date atom-chunk] > > > (after? from-date (feed-date-to-clj-date (:UPDATED atom-chunk)))) > > > > > And here is how I run it forever: > > > > > (fetch-atom-feed "https://producta.blah.com/feed/current") > > > > > And here is how I run it with a predicate: > > > > > (def date-from (.parse (java.text.SimpleDateFormat. "yyyy-MM-dd") > > > "2013-05-27")) > > > (take-while #(more-feed-chunks-needed? date-from %) (fetch-atom-feed " > > >https://producta.blah.com/feed/current")) > > > > > Maybe this is too detailed for the group (do let me know) but > otherwise I > > > would appreciate your advice / tips on what I could try. > > > > > Thanks > > > > > Ray > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.