Class: Hubstats::Label
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Hubstats::Label
- Defined in:
- app/models/hubstats/label.rb
Class Method Summary collapse
-
.count_by_pull_requests(pull_requests) ⇒ Object
Public - Counts all of the labels that are assigned to one of the PRs that is passed in.
-
.first_or_create(label) ⇒ Object
Public - Checks if the label is currently existing, and if it isn’t, then makes a new label with the specifications that are passed in.
- .record_timestamps ⇒ Object
Class Method Details
.count_by_pull_requests(pull_requests) ⇒ Object
Public - Counts all of the labels that are assigned to one of the PRs that is passed in. This is then merged with the list of PRs. It also shows a count of the number of PRs with each specific label.
pull_requests - the PRs that are shown on the given index page
Returns - the labels data
16 17 18 19 20 21 22 23 |
# File 'app/models/hubstats/label.rb', line 16 def self.count_by_pull_requests(pull_requests) select("hubstats_labels.*") .select("COUNT(hubstats_labels_pull_requests.pull_request_id) AS pull_request_count") .joins(:pull_requests).merge(pull_requests) .having("pull_request_count > 0") .group("hubstats_labels.id") .order("pull_request_count DESC") end |
.first_or_create(label) ⇒ Object
Public - Checks if the label is currently existing, and if it isn’t, then makes a new label with the specifications that are passed in.
label - the info that’s passed in about the new label
Returns - the label
33 34 35 36 37 38 39 |
# File 'app/models/hubstats/label.rb', line 33 def self.first_or_create(label) if exists = Hubstats::Label.where(name: label[:name]).first return exists else Label.new(name: label[:name], url: label[:url], color: label[:color]) end end |
.record_timestamps ⇒ Object
4 |
# File 'app/models/hubstats/label.rb', line 4 def self.; false; end |