Skip to content

qx_committer by insts

RichMorin edited this page Dec 31, 2012 · 5 revisions

Ignored

Query Example: committer-by-insts

committer-by-insts - list committer email addresses by instants

This example comes from the core.clj file in Devin Walter's nifty codeq-playground.

Problem

You need to find out, for some number of instants, the email addresses of the committers.

Solution

First, define the committer-by-insts function, then use it in a pipeline with commit-dates.

(defn committer-by-insts
  "email addresses of committers, based on date/time"
  [instants]
  (d/q '[:find ?email
         :in $ [?instant ...]
         :where
         [ ?commit  :commit/committedAt  ?instant  ]    ;; get commit for an instant
         [ ?commit  :commit/committer    ?user     ]    ;; and its committer
         [ ?user    :email/address       ?email    ] ]  ;; and the committer's email
   db
   instants))

The function is used as follows:

(-> "clojure.core/pmap"
     commit-dates
     committer-by-insts)

Discussion

This function assumes that db is a database connection.

See Also

Clone this wiki locally