-
Notifications
You must be signed in to change notification settings - Fork 0
qx_first and latest commit by author email
RichMorin edited this page Dec 31, 2012
·
5 revisions
first-and-latest-commit-by-author-email
- first and latest commit, by author email
This example comes from the core.clj file in Devin Walter's nifty codeq-playground.
You need to get date/time values of an author's first and latest commits, based on her email address.
Ask Codeq for date/time values of all commits where the author is the user, based on her email address. Return the email address, along with the minimum and maximum date/time values:
(defn first-and-latest-commit-by-author-email
"first and latest commit, by author email"
[email]
(d/q '[:find ?email (min ?date) (max ?date)
:in $ ?email
:where
[ ?commit :commit/committedAt ?date ] ;; get commits and dates
[ ?commit :commit/author ?user ] ;; get users for a commit
[ ?user :email/address ?email ] ] ;; filter by email address
db email))
The function is used as follows:
(first-and-latest-commit-by-author-email "[email protected]")
This function assumes that db
is a database connection.