Code Monkey home page Code Monkey logo

git-stats's Introduction

Git stats

Provide MR/PR statistics for your Gitlab/GitHub projects

Install

Run npm install -g gitflows-stats

Prerequisite

Generate a token to use the API:

  • Gitlab
    • Have a token with enough privilege (read_api)
  • GitHub
    • Generate a personal access token

Usage

  • gitflows-stats --help will print:

    Usage: index [options] [command]
    
    Options:
    -h, --help                                        display help for command
    
    Commands:
    gitlab [options] <token> <projectId> <period>     Provide merge requests statistics on a Gitlab project for a given period
    github [options] <token> <owner> <repo> <period>  Provide pull requests statistics on a GitHub project for a given period
    help [command]                                    display help for command
  • the <period> parameter has an optional end and may be in the following format:

    • 2023-01-01,2023-01-31 will retrieve all the merged events between these 2 dates
    • 2023-01-01 will retrieve all the merged events between the given date and now
  • gitflows-stats gitlab <TOKEN> <PROJECT_ID> <PERIOD> ( in the following format 2023-01-01,2023-01-31) will print:

    {
      "average": {
        "months": 0,
        "days": 4,
        "hours": 22,
        "minutes": 48,
        "seconds": 0
      },
      "total": {
        "merged": 15,
        "closed": 2,
        "opened": 3,
        "all": 20
      },
      "data": [
        [
          2023,
          [
            {
              "Week 9": 1
            },
            {
              "Week 10": 5
            },
            {
              "Week 11": 3
            },
            {
              "Week 12": 2
            },
            {
              "Week 13": 2
            },
            {
              "Week 14": 2
            }
          ]
        ]
      ]
    }
  • gitflows-stats gitlab <TOKEN> <PROJECT_ID> <PERIOD> --format html ( in the following format 2023-01-01,2023-01-31) will generate a report folder with an index.html where the command has been executed.

    The report will automatically open after generation.

    example:

Available output format

  • Console (Default): print a lightweight statistics in JSON into the console
  • HTML: generates a HTML file, opening automatically in your browser
  • CSV: generates a CSV file with all raws data

git-stats's People

Contributors

bbougon avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

git-stats's Issues

[Main graph] Shorten months display name

When the main graph holds a long period, the X-axis could have a shorter displayed name for months

Solution
For long periods (more than one year), display shorten months name (e.g: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

chart_screenshot

Impossible to generate statistics due with unclear message in console

Impossible to generate statistics due to payload.map is not a function
Trying to generate statistics, the feedback given is an error in the console which gives no insight about what happened

Steps to Reproduce

  1. Give a wrong parameter needed by GitHub or Gitlab API (wrong token, wrong project id or name)
  2. Execute gitflows-stats

Expected behavior
In case of error from the API, a clear message explaining why it failed should be displayed in the console.

Make gitlab server url configurable

It is not possible for now to get statistics from a self hosted gitlab server. Indeed, "gitlab.com" url is hardcoded.

Could you make this configurable so that we can get stats from a self hosted server ? (by adding a command line arg for instance)

Thanks for this implementation.

[Chart] Chart display weeks instead of months

Some long periods are displayed in weeks instead of months
Getting statistics for a period over 2 months, instead of having months displayed I see the weeks

Steps to Reproduce

  1. Run the command with a period of exactly 12 months (e.g 2022-04-01,2023-04-01 ) and the output in html (e.g: gitflows-stats gitlab TOKEN PROJECT_ID 2022-04-01,2023-04-01 --format html)

Expected behavior
I should see the twelve months displayed

Screenshots
week_issue

Upper time bound is ignored

Describe the bug

Running the following command

gitflows-stats github $(cat github-token) input-output-hk hydra 2022-09-01 2023-05-31 --format html

yields this stats page

Screenshot 2023-06-16 at 09 34 27

I would have expected the period to end on May 31st. This is not only annoying for display but skews the stats and makes it impossible to extract evolution of average over time, eg. a sliding window of 3 months for example, in order to identify trends.

Display dates instead of week numbers

When one selects the Weeks tab, a weekly breakdown of the stats is displayed.

Screenshot 2023-07-08 at 09 16 37

It would probably be more useful if instead of week 3 it said 2022-01-18 for example, eg. provide dates as the horizontal axis unit instead of week number.

Can't retrieve stats for a public github repo

Describe the bug

Running the following command from master:

gitflows-stats github $(cat github-token) input-output-hk hydra 2023-01-01 2023-06-30

Yields the following somewhat cryptic output:

Paginate | ████████████████████████████████████████ | 9/9
Something wrong happened:
TypeError: Cannot read properties of undefined (reading 'build')

I generated a new PAT and checked it's working with a raw curl on the GH API.

[Aggregated stats] Display human readable average time

Both average duration are just the exact same value (rounding aside) displayed in different unit (day(s) and hours).
It would be more human readable to have only one average time expressed in time unit.

Solution
Display one value but in months, days and hours instead of a decimal number of days (or decimal number of hours)

Capture d’écran 2023-04-03 à 23 48 30

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.