Module: GitHub::Client::Stats

Included in:
GitHub::Client
Defined in:
lib/github_api_v3/client/stats.rb

Overview

Methods for the Repo Statistics API.

A notice about caching from GitHub’s API: Computing repository statistics is an expensive operation, so we try to return cached data whenever possible. If the data hasn’t been cached when you query a repository’s statistics, you’ll receive a 202 response; a background job is also fired to start compiling these statistics. Give the job a few moments to complete, and then submit the request again. If the job has completed, that request will receive a 200 response with the statistics in the response body. Repository statistics are cached by the SHA of the repository’s default branch, which is usually master; pushing to the default branch resets the statistics cache.

Instance Method Summary collapse

Instance Method Details

#code_frequency(owner, repo) ⇒ Array

Get the number of additions and deletions per week.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

See Also:



47
48
49
# File 'lib/github_api_v3/client/stats.rb', line 47

def code_frequency(owner, repo)
  get "/repos/#{owner}/#{repo}/stats/code_frequency"
end

#commit_activity(owner, repo) ⇒ Array

Get the last year of commit activity data.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

    Commit activity list.

See Also:



37
38
39
# File 'lib/github_api_v3/client/stats.rb', line 37

def commit_activity(owner, repo)
  get "/repos/#{owner}/#{repo}/stats/commit_activity"
end

#contributors_list(owner, repo) ⇒ Array

Get contributors list with additions, deletions, and commit counts.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

    Contributor list.

See Also:



27
28
29
# File 'lib/github_api_v3/client/stats.rb', line 27

def contributors_list(owner, repo)
  get "/repos/#{owner}/#{repo}/stats/contributors"
end

#participation(owner, repo) ⇒ Array

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

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

    Contributor list.

See Also:



57
58
59
# File 'lib/github_api_v3/client/stats.rb', line 57

def participation(owner, repo)
  get "/repos/#{owner}/#{repo}/stats/participation"
end

#punch_card(owner, repo) ⇒ Array

Get the number of commits per hour in each day.

Parameters:

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Array)

See Also:



67
68
69
# File 'lib/github_api_v3/client/stats.rb', line 67

def punch_card(owner, repo)
  get "/repos/#{owner}/#{repo}/stats/punch_card"
end