Skip to content

Commit

Permalink
Enhance invitation logic to include only approved funding sources and…
Browse files Browse the repository at this point in the history
… add scope for funding sources with project allocations
  • Loading branch information
andrew committed Mar 5, 2025
1 parent e4cc293 commit 9878c0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def decline_deadline
end

def send_invitations
project_allocations.select{|pa| pa.funding_source.blank?}.each do |pa|
project_allocations.select{|pa| pa.funding_source.blank? || !pa.funding_source.approved? }.each do |pa|
pa.send_invitation
end
end
Expand Down
3 changes: 3 additions & 0 deletions app/models/funding_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class FundingSource < ApplicationRecord
scope :platform, ->(platform) { where(platform: platform) }
scope :approved, -> { where(platform: APPROVED_PLATFORMS) }

scope :with_project_allocations, -> { where('EXISTS (SELECT 1 FROM project_allocations WHERE project_allocations.funding_source_id = funding_sources.id)') }

def self.open_collective_github_sponsors_mapping
@open_collective_github_sponsors_mapping ||= begin
url = 'https://raw.githubusercontent.com/opencollective/opencollective-tools/refs/heads/main/github-sponsors/csv-import-mapping.json'
Expand Down Expand Up @@ -79,6 +81,7 @@ def to_s

def sync
fetch_collective
fetch_github_sponsors
update(last_synced_at: Time.now)
end

Expand Down

0 comments on commit 9878c0c

Please sign in to comment.