pdehaan / repo-health-report

Issue tracker stats for repos.
https://repo-health-report.now.sh/
Mozilla Public License 2.0
3 stars 0 forks source link

Metrics metrics metrics #2

Open pdehaan opened 4 years ago

pdehaan commented 4 years ago

What are they? What do we care about? How to you measure quality or "health"?

Random thoughts in random order (but numbers are easier to reference than bullets)...

  1. number of open issues over time (to try and infer trends).
  2. number of new issues per day (hard to gauge since hard to detect a flat number of issues that never change, versus constant open-closed issues that appear flat)
  3. average age of open issues (to try and infer churn, which semi-mitigates the issue above of flatline of unmoving bugs vs 1-open-1-closed)
  4. number and age of unmerged PRs? (I kind of like this as a general health metric -- how stale are PRs)
pdehaan commented 4 years ago

Basic proof of concept, but calculate the average age of issues by figuring out their cumulative age (from created_at date) and dividing by the total number of currently open issues:

function issueStats(issues, now = new Date()) {
  const totalAgeMs = issues.reduce((totalMs, {created_at}) => totalMs + (now - new Date(created_at)), 0);
  const avgAgeMs = totalAgeMs / issues.length;
  return {
    avgAgeMs,
    avgAge: ms(avgAgeMs),
    issueCount: issues.length
  };
}

That should give us something similar to the following output:

{
  "owner": "mozilla",
  "repo": "blurts-server",
  "date": "2020-03-31",
  "now": "2020-04-01T00:04:38.245Z",
  "issueStats": {
    "avgAgeMs": 22938489197.606636,
    "avgAge": "265d",
    "issueCount": 211
  },
  ...
}

Silly numbers like "265d" are notoriously tricky to work with in real life (since you don't always know the duration to expect), so maybe we convert to "ms" friendly times on the front end instead of in the data.

pdehaan commented 4 years ago

I guess worth noting is that I don't suppose Bugzilla has a concept of "pull requests", so that might only be for GitHub repos.