Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused configuration and code #1430

Merged
merged 8 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
},
"RACK_ENV": {
"required": true
},
"ES_HOST": {
"required": true
}
},
"formation": {},
Expand Down
1 change: 0 additions & 1 deletion app/views/datasets/_additional_info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<% if i['access_constraints'] %>
<dt><%= t('.inspire_access_constraints') %></dt>
<% constraints = i['access_constraints'] %>
<% pp constraints %>
<dd><%= constraints.is_a?(String) ? constraints : constraints.first || t('.inspire_access_constraints_unspecified') %></dd>
<% end %>
<% if i['guid'] %>
Expand Down
81 changes: 0 additions & 81 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,6 @@
</script>
<% end %>

<script>
<% if Rails.application.config.analytics_tracking_id.present? %>
var analyticsInit = function() {
var consentCookie = window.GOVUK.getConsentCookie();

if (consentCookie && consentCookie["usage"]) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga')

ga('create', '<%= Rails.application.config.analytics_tracking_id %>', 'auto')
var dimensions = {}

$(document).ready(function() {
dimensions['dimension11'] = 'find-open-data'
ga('send', 'pageview', dimensions)
$('[data-ga-event]').on('click', sendAnalyticsEvent)
})

// Analytics event firing
function sendAnalyticsEvent() {
var eventType = $(this).data('ga-event')
var orgName = $(this).data('ga-publisher')
var eventParams = {}
switch (eventType) {
case 'download':
eventParams = {
hitType: 'event',
eventCategory: 'datafile',
eventAction: 'download',
eventLabel: $(this).attr('href'),
dimension4: orgName,
dimension5: $(this).data('ga-format'),
dimension11: 'find-open-data'
}
break
case 'contact':
eventParams = {
hitType: 'event',
eventCategory: 'contact-details',
eventAction: 'click',
eventLabel: orgName,
dimension4: orgName,
dimension11: 'find-open-data'
}
break
case 'preview':
eventParams = {
hitType: 'event',
eventCategory: 'datafile-preview',
eventAction: 'click',
eventLabel: $(this).attr('href'),
dimension4: orgName,
dimension5: $(this).data('ga-format'),
dimension11: 'find-open-data'
}
break
case 'preview-download':
eventParams = {
hitType: 'event',
eventCategory: 'datafile-preview',
eventAction: 'download',
eventLabel: $(this).attr('href'),
dimension4: orgName,
dimension5: $(this).data('ga-format'),
dimension11: 'find-open-data'
}
break
}
ga('send', eventParams)
}
}
};
<% else %>
var analyticsInit = function() { /* Analytics not configured. */ };
<% end %>
window.GOVUK = window.GOVUK || {};
window.GOVUK.analyticsInit = analyticsInit;
</script>

<meta charset="utf-8">
<title><%= content_for?(:page_title) ? yield(:page_title) + " - " + t('.site_name') : t('.site_name') %></title>

Expand Down
23 changes: 0 additions & 23 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

if ENV["VCAP_SERVICES"]
services = JSON.parse(ENV["VCAP_SERVICES"])

if services.key?("user-provided")
# Extract UPSes and pull out secrets configs
user_provided_services = services["user-provided"].select { |s| s["name"].include?("secrets") }
credentials = user_provided_services.map { |s| s["credentials"] }.reduce(:merge)

# Take each credential and assign to ENV
credentials.each do |k, v|
# Don't overwrite existing env vars
ENV[k.upcase] ||= v
end
end
end

module FindDataBeta
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
Expand All @@ -46,14 +30,7 @@ class Application < Rails::Application
# https://github.com/alphagov/govuk-frontend/issues/1350
config.assets.css_compressor = nil

config.action_dispatch.rescue_responses["Datafile::DatafileNotFound"] = :not_found
config.action_dispatch.rescue_responses["Dataset::DatasetNotFound"] = :not_found
config.exceptions_app = routes

config.analytics_tracking_id = ENV["GA_TRACKING_ID"]
config.i18n.load_path += Dir[Rails.root.join("config/locales/**/**/*.{rb,yml}")]
config.filter_parameters << :password
config.filter_parameters << :password_confirmation

config.ssl_options = { hsts: { expires: 1.week } }

Expand Down
3 changes: 0 additions & 3 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"Cache-Control" => "public, max-age=#{1.hour.to_i}",
}

# Trun off debug mode to speed up feature tests
config.assets.debug = false

# Precompile assets to speed up feature tests
config.assets.compress = true

Expand Down
9 changes: 0 additions & 9 deletions config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,3 @@
end

Kaminari::Hooks.init if defined?(Kaminari::Hooks)

# This is a workaround suggested by the Kaminari team to fix a security issue:
# https://github.com/kaminari/kaminari/security/advisories/GHSA-r5jw-62xg-j433
#
# Ideally we would upgrade to Kaminari 1.2, but we can't because:
# https://github.com/elastic/elasticsearch-rails/issues/966
module Kaminari::Helpers
PARAM_KEY_EXCEPT_LIST = %i[authenticity_token commit utf8 _method script_name original_script_name].freeze
end
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR $APP_HOME
COPY Gemfile* .ruby-version ./
RUN bundle install
COPY . ./
RUN ES_HOST=x rails assets:precompile && rm -fr log
RUN rails assets:precompile && rm -fr log


FROM $base_image
Expand Down
1 change: 0 additions & 1 deletion test-environment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
# source this script before running tests to set the correct env vars
export RAILS_ENV=test
export ES_INDEX=datasets-test
export CKAN_DOMAIN=testdomain