123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::Stats

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/stats.rb

Overview

Instance Method Summary

Instance Method Details

#code_frequency_stats(repo, options = {}) ⇒ Array<Sawyer::Resource>

Get the number of additions and deletions per week

Examples:

Get code frequency stats for octokit

@client.code_frequency_stats('octokit/octokit.rb')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • retry_timeout (Hash)

    a customizable set of options

  • retry_wait (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    Weekly aggregate of the number of additions and deletions pushed to a repository.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 47

def code_frequency_stats(repo, options = {})
  get_stats(repo, 'code_frequency', options)
end

#commit_activity_stats(repo, options = {}) ⇒ Array<Sawyer::Resource>

Get the last year of commit activity data

Examples:

Get commit activity for octokit

@client.commit_activity_stats('octokit/octokit.rb')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • retry_timeout (Hash)

    a customizable set of options

  • retry_wait (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    The last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 33

def commit_activity_stats(repo, options = {})
  get_stats(repo, 'commit_activity', options)
end

#contributor_stats(repo, options = {})

Alias for #contributors_stats.

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 21

alias contributor_stats contributors_stats

#contributors_stats(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #contributor_stats

Get contributors list with additions, deletions, and commit counts

Examples:

Get contributor stats for octokit

@client.contributors_stats('octokit/octokit.rb')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • retry_timeout (Hash)

    a customizable set of options

  • retry_wait (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    Array of contributor stats

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 18

def contributors_stats(repo, options = {})
  get_stats(repo, 'contributors', options)
end

#get_stats(repo, metric, options = {}) ⇒ Array<Sawyer::Resource> or nil (private)

This method is for internal use only.

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • metric (String)

    The metrics you are looking for

Returns:

  • (Array<Sawyer::Resource> or nil)

    Stats in metric-specific format, or nil if not yet calculated.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 90

def get_stats(repo, metric, options = {})
  options = options.dup
  if retry_timeout = options.delete(:retry_timeout)
    retry_wait = options.delete(:retry_wait) || 0.5
    timeout = Time.now + retry_timeout
  end
  loop do
    data = get("#{Repository.path repo}/stats/#{metric}", options)
    return data if last_response.status == 200
    return [] if last_response.status == 204
    return nil unless retry_timeout
    return nil if Time.now >= timeout

    sleep retry_wait if retry_wait
  end
end

#participation_stats(repo, options = {}) ⇒ Sawyer::Resource

Get the weekly commit count for the repo owner and everyone else

Examples:

Get weekly commit counts for octokit

@client.participation_stats("octokit/octokit.rb")

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • retry_timeout (Hash)

    a customizable set of options

  • retry_wait (Hash)

    a customizable set of options

Returns:

  • (Sawyer::Resource)

    Total commit counts for the owner and total commit counts in all. all is everyone combined, including the owner in the last 52 weeks. If you’d like to get the commit counts for non-owners, you can subtract all from owner.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 63

def participation_stats(repo, options = {})
  get_stats(repo, 'participation', options)
end

#punch_card(repo, options = {})

Alias for #punch_card_stats.

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 80

alias punch_card punch_card_stats

#punch_card_stats(repo, options = {}) ⇒ Array<Array> Also known as: #punch_card

Get the number of commits per hour in each day

Examples:

Get octokit punch card

@octokit.punch_card_stats

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • retry_timeout (Hash)

    a customizable set of options

  • retry_wait (Hash)

    a customizable set of options

Returns:

  • (Array<Array>)

    Arrays containing the day number, hour number, and number of commits

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/stats.rb', line 77

def punch_card_stats(repo, options = {})
  get_stats(repo, 'punch_card', options)
end