Skip to content

Instantly share code, notes, and snippets.

@t-ob
Created December 18, 2012 12:37
Show Gist options
  • Save t-ob/4327606 to your computer and use it in GitHub Desktop.
Save t-ob/4327606 to your computer and use it in GitHub Desktop.
(def tob-feed-ids ["180893462012339" "289169977804676"])
(def tob-interval {:from (parse (formatters :date) "2012-12-10"), :to (now)})
(defn get-attr-count [attr post]
(or (get-in post [attr :count]) 0))
(def tob-query-result
(io/with-fs-tmp [_ tmp]
(let [feed-ids tob-feed-ids
feed-profiles (->> tob-feed-ids
(map #(vector % (-> % facebook/profile* (select-keys [:name :likes]))))
(reduce conj {}))
posts (c/lazy-generator tmp
(reduce #(into %1 (feed-posts %2 tob-interval)) (lazy-seq) feed-ids))]
(println feed-profiles)
(??<- [?feed-id ?feed-name ?id ?engagement]
(posts ?id ?feed-id ?item)
(read-string ?item :> ?post)
(get-in ?post [:from :id] :> ?from-id)
(get-in ?post [:message] :> ?message)
(get feed-profiles ?feed-id :> ?profile)
(get ?profile :name :> ?feed-name)
(get ?profile :likes :> ?feed-likes)
(get-attr-count :comments ?post :> ?comments)
(get-attr-count :likes ?post :> ?likes)
(get-attr-count :shares ?post :> ?shares)
(+ ?comments ?likes ?shares :> ?sum)
(div ?sum ?likes :> ?engagement)
(= ?feed-id ?from-id)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment