Skip to content

Commit

Permalink
[CPDLP-3814] remove NPQLeadProvider model and table
Browse files Browse the repository at this point in the history
  • Loading branch information
mooktakim committed Dec 18, 2024
1 parent 8e08b12 commit 384519e
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def participant_declaration_for_lead_provider
end

def access_scope
LeadProviderApiToken.joins(cpd_lead_provider: [:lead_provider]) + LeadProviderApiToken.joins(cpd_lead_provider: [:npq_lead_provider])
LeadProviderApiToken.joins(cpd_lead_provider: [:lead_provider])
end

def serializer_class
Expand Down
1 change: 0 additions & 1 deletion app/models/cpd_lead_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class CpdLeadProvider < ApplicationRecord
has_paper_trail

has_one :lead_provider
has_one :npq_lead_provider
has_many :participant_declarations
has_many :statements, class_name: "Finance::Statement"
has_many :ecf_statements, class_name: "Finance::Statement::ECF"
Expand Down
2 changes: 0 additions & 2 deletions app/models/finance/statement/npq.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class Finance::Statement::NPQ < Finance::Statement
has_one :npq_lead_provider, through: :cpd_lead_provider

STATEMENT_TYPE = "npq"

def payable!
Expand Down
15 changes: 0 additions & 15 deletions app/models/npq_lead_provider.rb

This file was deleted.

89 changes: 0 additions & 89 deletions app/serializers/finance/npq/assurance_report/csv_serializer.rb

This file was deleted.

180 changes: 0 additions & 180 deletions app/services/oneoffs/npq/migrate_declarations_between_statements.rb

This file was deleted.

7 changes: 0 additions & 7 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,6 @@
- schedule_id
- created_at
- updated_at
:npq_lead_providers:
- id
- name
- created_at
- updated_at
- cpd_lead_provider_id
- vat_chargeable
:local_authorities:
- id
- created_at
Expand Down
21 changes: 1 addition & 20 deletions db/legacy_seeds/initial_seed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,7 @@
.tap { |pp| pp.html = Rails.root.join("data/privacy_policy.html").read }
.save!

[
{ name: "Ambition Institute", id: "9e35e998-c63b-4136-89c4-e9e18ddde0ea" },
{ name: "Best Practice Network", id: "57ba9e86-559f-4ff4-a6d2-4610c7259b67" },
{ name: "Church of England", id: "79cb41ca-cb6d-405c-b52c-b6f7c752388d" },
{ name: "Education Development Trust", id: "21e61f53-9b34-4384-a8f5-d8224dbf946d" },
{ name: "School-Led Network", id: "bc5e4e37-1d64-4149-a06b-ad10d3c55fd0" },
{ name: "LLSE", id: "230e67c0-071a-4a48-9673-9d043d456281" },
{ name: "Teacher Development Trust", id: "30fd937e-b93c-4f81-8fff-3c27544193f1" },
{ name: "Teach First", id: "a02ae582-f939-462f-90bc-cebf20fa8473" },
{ name: "UCL Institute of Education", id: "ef687b3d-c1c0-4566-a295-16d6fa5d0fa7" },
{ name: "National Institute of Teaching", id: "3ec607f2-7a3a-421f-9f1a-9aca8a634aeb" },
].each do |hash|
NPQLeadProvider.find_or_create_by!(name: hash[:name], id: hash[:id])
end

all_provider_names = (LeadProvider.pluck(:name) + NPQLeadProvider.pluck(:name)).uniq
all_provider_names = LeadProvider.pluck(:name).uniq

all_provider_names.each do |name|
CpdLeadProvider.find_or_create_by!(name:)
Expand All @@ -64,7 +49,3 @@
LeadProvider.find_each do |lp|
lp.update!(cpd_lead_provider: CpdLeadProvider.find_by(name: lp.name))
end

NPQLeadProvider.find_each do |lp|
lp.update!(cpd_lead_provider: CpdLeadProvider.find_by(name: lp.name))
end
22 changes: 22 additions & 0 deletions db/migrate/20241218170200_drop_table_npq_lead_providers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

class DropTableNPQLeadProviders < ActiveRecord::Migration[7.1]
def up
remove_foreign_key :npq_lead_providers, :cpd_lead_providers
drop_table :npq_lead_providers
end

def down
create_table :npq_lead_providers, id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text :name, null: false
t.datetime :created_at, null: false
t.datetime :updated_at, null: false
t.uuid :cpd_lead_provider_id
t.boolean :vat_chargeable, default: true

t.index :cpd_lead_provider_id, name: "index_npq_lead_providers_on_cpd_lead_provider_id"
end

add_foreign_key :npq_lead_providers, :cpd_lead_providers
end
end
Loading

0 comments on commit 384519e

Please sign in to comment.