Skip to content

Commit

Permalink
Remove unused scopes and methods
Browse files Browse the repository at this point in the history
Scopes and methods to return all but ISPF funds, activities, and reports
are now unused. They were only in use when the app had a feature flag to
enable hiding everything to do with ISPF.

I did hesitate for a bit about keeping this code "just in case", but
ultimately we know that in general, unused code is a recipe for
confusion and an increased burden of maintenance, and it can always be
added back if it's needed in future.
  • Loading branch information
CristinaRO committed Nov 29, 2023
1 parent ebbf6fc commit 85355b0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 21 deletions.
2 changes: 0 additions & 2 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ class Activity < ApplicationRecord
where(programme_status: ["completed", "stopped", "cancelled"])
}

scope :not_ispf, -> { where.not(source_fund_code: Fund.by_short_name("ISPF")) }

def self.new_child(parent_activity:, partner_organisation:, is_oda: nil, &block)
attributes = ActivityDefaults.new(
parent_activity: parent_activity,
Expand Down
4 changes: 0 additions & 4 deletions app/models/fund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def all
valid_codes.map { |code| new(code) }
end

def not_ispf
(valid_codes - [4]).map { |code| new(code) }
end

def codelist
Codelist.new(type: "fund_types", source: "beis")
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class Report < ApplicationRecord
where(fund_id: activity.associated_fund.id, organisation_id: activity.organisation_id, is_oda: activity.is_oda)
end

scope :not_ispf, -> { where.not(fund_id: Activity.by_roda_identifier("ISPF").id) }

def self.editable_for_activity(activity)
editable.for_activity(activity).first
end
Expand Down
13 changes: 0 additions & 13 deletions spec/models/fund_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@
end
end

describe ".not_ispf" do
it "returns a Fund for every entry in the 'fund_types' codelist except for ISPF" do
codelist = Codelist.new(type: "fund_types", source: "beis")

funds = described_class.not_ispf
expect(funds.size).to eq(codelist.list.size - 1)

non_ispf_ids = [1, 2, 3]
ids = funds.map(&:id)
expect(ids).to eq(non_ispf_ids)
end
end

describe "#gcrf?" do
let(:fund) { described_class.new(id) }
subject { fund.gcrf? }
Expand Down

0 comments on commit 85355b0

Please sign in to comment.