Patrick DeVivo Avatar

Patrick DeVivo

Patrick DeVivo github.com

A fluent GraphQL library for Go

This package wraps the graphql-go/graphql implementation to provide a “fluent” pattern for constructing GraphQL queries in Go. This can be valuable in situations where dynamic queries are desired: when the fields of a GraphQL query (or mutation) are not known until runtime. For most other use cases, plain query strings or a helper library such as this should be sufficient.

I wonder if this would change Mislav’s unpopular GraphQL/Go opinion

Patrick DeVivo github.com

Reqlite lets you query Redis with SQL

Patrick DeVivo:

This is a project in Go that compiles to a SQLite runtime loadable extension, which brings Redis commands into a SQL context. This allows you to write SQL queries against data in a Redis instance, using Redis commands like LRANGE as SQL functions.

Experimental for now. But why? Patrick says:

In general, Redis is fairly accessible from many programming languages, and any query using reqlite could probably be implemented in a language of your choice using a Redis client. However, sometimes declarative SQL can be a better choice to express what you’re looking for, and that’s where this project may be most useful.

Patrick DeVivo try.askgit.com

Try AskGit SQL in your browser

Remember Patrick DeVivo’s super cool AskGit project where you can query your git repo’s history with SQL? Well, now you can kick the tires without installing a thing by using AskGit’s new web interface!

Here’s an example query where we learn that I do most of my coding (or committing, at least) on Mondays and Tuesdays while Adam and Gerhard lean towards Friday.

Patrick DeVivo augmentable.medium.com

Identifying code churn with AskGit SQL

In which I detail A SQL query that helps you identify files in a codebase that have “churned” in the past year. In other words, list the files that have been changed by the most number of commits in the last year.

SELECT file,
       COUNT(*)
FROM   stats
       JOIN commits
         ON stats.commit_id = commits.id
WHERE  commits.author_when > DATE('now', '-12 month')
       AND commits.parent_count < 2 -- ignore merge commits
GROUP  BY file
ORDER  BY COUNT(*) DESC
LIMIT  50

Patrick DeVivo askgit.com

AskGit - query your git repo with SQL

Built in Go, askgit is an open source CLI and coming soon web interface (linked above). With this tool in your toolbox, you can mine your repo for info like commit count by author on each day of the week:

SELECT
    count(*) AS commits,
    count(CASE WHEN strftime('%w',author_when)='0' THEN 1 END) AS sunday,
    count(CASE WHEN strftime('%w',author_when)='1' THEN 1 END) AS monday,
    count(CASE WHEN strftime('%w',author_when)='2' THEN 1 END) AS tuesday,
    count(CASE WHEN strftime('%w',author_when)='3' THEN 1 END) AS wednesday,
    count(CASE WHEN strftime('%w',author_when)='4' THEN 1 END) AS thursday,
    count(CASE WHEN strftime('%w',author_when)='5' THEN 1 END) AS friday,
    count(CASE WHEN strftime('%w',author_when)='6' THEN 1 END) AS saturday,
    author_email
FROM commits GROUP BY author_email ORDER BY commits

Patrick DeVivo github.com

Using SQL to query git repos

gitqlite is a tool for running SQL queries on git repositories. It implements SQLite virtual tables and uses go-git. It’s meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

Mine your repo’s history for goodies. Here’s how to get commit count by author email:

SELECT author_email, count(*) FROM commits GROUP BY author_email ORDER BY count(*) DESC

Patrick DeVivo github.com

Identify the most relevant git contributors based on commit recency, frequency, and impact

gitpert measures the “pertinence” of git authors as a time-decayed measure of LOC added and removed to a repository (or a set of files in a repository). It’s meant to help identify who the most relevant contributors are based on commit recency, frequency and impact.

Cool tool, as long as we don’t forget about non-code contributors.

Patrick DeVivo tickgit.com

Never forget a #TODO comment

Patrick DeVivo:

tickgit is a tool for software developers to do project management within their codebase. It searches code comments for markers indicating areas and files worth returning to (TODO, FIXME, etc). It can be used to proactively identify areas of technical debt, or handle day-to-day to-do items and checklists.

Free for public repos and open source.

Patrick DeVivo Medium (via Scribe)

Looking at Kubernetes’ 2k+ TODO comments

Patrick DeVivo pointed tickgit at Kubernetes’ source code and discovered that the team has a lot TODO…

  • 2,380 TODOs across 1,230 files from 363 distinct authors
  • 489 TODOs were added in 2019 so far
  • 860 days (or 2.3 years) is the average age of a TODO

That’s just a taste of what they found. The article has more info and some analysis to boot.

Player art
  0:00 / 0:00