-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display % in a table format and add support for :unmerged (#33)
* Refactor buckets into a module. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Show stats for all categories. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Added --status=merged/unmerged. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Correct % totals. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
- Loading branch information
Showing
17 changed files
with
559 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GITHUB_API_TOKEN= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
.cache | ||
data | ||
.DS_Store | ||
coverage | ||
.env | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
module GitHub | ||
module Buckets | ||
def members | ||
buckets[:members] || [] | ||
end | ||
|
||
def contractors | ||
buckets[:contractors] || [] | ||
end | ||
|
||
def external | ||
buckets[:external] || [] | ||
end | ||
|
||
def unknown | ||
buckets[:unknown] || [] | ||
end | ||
|
||
def all | ||
to_a | ||
end | ||
|
||
def all_members | ||
members.concat(contractors) | ||
end | ||
|
||
def all_external | ||
external | ||
end | ||
|
||
def all_external_percent | ||
return 0 unless all.any? | ||
|
||
((all_external.size.to_f / all.size) * 100).to_i | ||
end | ||
|
||
def percent | ||
buckets.map do |k, v| | ||
pc = ((v.size.to_f / all.size) * 100).round(1) | ||
[k, pc] | ||
end.to_h | ||
end | ||
|
||
def self.bucket(username) | ||
if GitHub::Data.members.include?(username.to_s) | ||
:members | ||
elsif GitHub::Data.contractors.include?(username.to_s) | ||
:contractors | ||
elsif GitHub::Data.external_users.include?(username.to_s) | ||
:external | ||
else | ||
:unknown | ||
end | ||
end | ||
|
||
def [](bucket) | ||
buckets[bucket] | ||
end | ||
|
||
def buckets | ||
raise NotImplementedError, :buckets | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.