Skip to content

Commit

Permalink
Add funding filter to package scope and implement critical funding do…
Browse files Browse the repository at this point in the history
…mains method
  • Loading branch information
andrew committed Jan 30, 2025
1 parent d782255 commit ed5d8f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/api/v1/packages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def critical
scope = scope.created_before(params[:created_before]) if params[:created_before].present?
scope = scope.updated_before(params[:updated_before]) if params[:updated_before].present?

scope = scope.with_funding if params[:funding].present?

if params[:sort].present? || params[:order].present?
sort = params[:sort] || 'updated_at'
sort = "(repo_metadata ->> 'stargazers_count')::text::integer" if params[:sort] == 'stargazers_count'
Expand Down
9 changes: 9 additions & 0 deletions app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,15 @@ def self.funding_domains
end
end

def self.critical_funding_domains
funding_domains = []
Package.critical.with_funding.active.find_each do |package|
funding_domains << package.funding_domains
end

funding_domains.flatten.group_by(&:itself).map{|k, v| [k, v.count]}.to_h.sort_by{|k, v| v}.reverse.to_h
end

def clean_up_duplicate_maintainerships
maintainer_ids = maintainerships.group(:maintainer_id).count.select{|k,v| v > 1}.keys
return if maintainer_ids.blank?
Expand Down

0 comments on commit ed5d8f4

Please sign in to comment.