Skip to content

Commit

Permalink
Remove references to PublicBodyCategory
Browse files Browse the repository at this point in the history
Replace PublicBodyCategory with Category. Only remaining references are
in the old models and temp rake tasks which migrates to the new Category
model.

Fixes #8179
  • Loading branch information
gbp committed Apr 11, 2024
1 parent 913c773 commit 3fab04b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
10 changes: 5 additions & 5 deletions app/controllers/public_body_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def list
count: @public_bodies.total_entries,
first_letter: @tag)
else
category_name = PublicBodyCategory.get.by_tag[@tag]
if category_name.nil?
category = PublicBody.category_list.find_by(category_tag: @tag)
if category.nil?
n_('Found {{count}} public authority matching the tag ' \
'‘{{tag_name}}’',
'Found {{count}} public authorities matching the tag ' \
Expand All @@ -152,11 +152,11 @@ def list
tag_name: @tag)
else
n_('Found {{count}} public authority in the category ' \
'‘{{category_name}}’',
'‘{{category_title}}’',
'Found {{count}} public authorities in the category ' \
'‘{{category_name}}’',
'‘{{category_title}}’',
count: @public_bodies.total_entries,
category_name: category_name)
category_title: category.title)
end
end

Expand Down
4 changes: 3 additions & 1 deletion app/models/public_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,9 @@ def self.with_tag(tag)
return all if tag.size == 1 || tag.nil? || tag == 'all'

if tag == 'other'
tags = PublicBodyCategory.get.tags - ['other']
tags = PublicBody.category_list.distinct.
where.not(category_tag: [nil, '', 'other']).
pluck(:category_tag)
where.not("EXISTS(#{tag_search_sql(tags)})")
else
original_with_tag(tag)
Expand Down
19 changes: 5 additions & 14 deletions lib/tasks/export.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ namespace :export do
default_scope -> { order(:info_request_batch_id, :public_body_id) }
end

class PublicBodyCategoryTranslation < ActiveRecord::Base
self.table_name = "public_body_category_translations"
belongs_to :public_body_category
end

class PublicBodyHeadingTranslation < ActiveRecord::Base
self.table_name = "public_body_heading_translations"
belongs_to :public_body_heading
end

class HasTagStringTag < ActiveRecord::Base
self.table_name = "has_tag_string_tags"
Expand Down Expand Up @@ -48,11 +39,11 @@ namespace :export do

to_run = to_run.split(",") if to_run

DataExport.csv_export(PublicBodyCategory, to_run)
DataExport.csv_export(PublicBodyHeading, to_run)
DataExport.csv_export(PublicBodyCategoryLink, to_run)
DataExport.csv_export(PublicBodyCategoryTranslation, to_run)
DataExport.csv_export(PublicBodyHeadingTranslation, to_run)
DataExport.csv_export(
Category, to_run, Category,
%w[id title description category_tag created_at updated_at]
)
DataExport.csv_export(CategoryRelationship, to_run)
DataExport.csv_export(InfoRequestBatchPublicBody, to_run)
DataExport.csv_export(HasTagStringTag,
to_run,
Expand Down

0 comments on commit 3fab04b

Please sign in to comment.