Skip to content

Commit

Permalink
Add ignorable_topics to exclude specific topics in project_topics
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jan 11, 2024
1 parent 735bef7 commit 583c593
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/models/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@ def self.topics
List.displayable.pluck(Arel.sql("repository -> 'topics'")).flatten.reject(&:blank?).group_by(&:itself).transform_values(&:count).sort_by{|k,v| v}.reverse
end

def self.ignorable_topics
['hacktoberfest']
end

def project_topics
projects.pluck(Arel.sql("repository -> 'topics'")).flatten.reject(&:blank?).group_by(&:itself).transform_values(&:count).sort_by{|k,v| v}.reverse
projects.pluck(Arel.sql("repository -> 'topics'")).flatten.reject(&:blank?).group_by(&:itself).transform_values(&:count).sort_by{|k,v| v}.reject{|k,v| List.ignorable_topics.include?(k) }.reverse
end

def shared_topics
project_topics.first(topics.length).to_h.keys & topics
end

def percentage_shared_topics
return nil if topics.length == 0
(shared_topics.length.to_f / topics.length.to_f * 100).round(2)
end

def description
Expand Down

0 comments on commit 583c593

Please sign in to comment.