Skip to content

Commit 8711c59

Browse files
SRCH-6124 dependencies cleanup (#1856)
* Remove unused gems *Remove flickraw, sidekiq, and related gems, and their initializers/configuration since they are not being used. Also remove turbolinks and retry_block. * Remove obsolete gems and unused CSS * Remove `chunky_png` and `curb` gems as they are no longer used. * Remove `turbolinks` and `turbolinks-source` gems as they are not used. * Remove `sidekiq` and `sidekiq-failures` gems as they are not used. * Remove the call to generate mobile CSS. * Remove the deprecated `AffiliateCss` class. * Add turbolinks back * Add flickraw gem and initialize flickr config * Remove unused mobile look and feel css template * Fix stub request status code * Update elapsed time expectations
1 parent 12ae847 commit 8711c59

File tree

16 files changed

+99
-329
lines changed

16 files changed

+99
-329
lines changed

Gemfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ gem 'rack-contrib', '~> 2.5.0'
99
gem 'rails-observers', '~> 0.1.5'
1010
gem 'responders', '~> 3.1.0'
1111
gem 'mysql2', '~> 0.5.5'
12-
gem 'curb', '~> 1.0.1'
1312
gem 'haml', '~> 6'
1413
gem 'will_paginate', '~> 3.3.1'
1514
gem 'nokogiri', '~> 1.16'
@@ -61,7 +60,6 @@ gem 'faraday_middleware', '~> 0.14.0'
6160
gem 'net-http-persistent', '~> 2.9.3'
6261
gem 'rash_alt', '~> 0.4.12', require: 'rash'
6362
gem 'geoip', '~> 1.6.4'
64-
gem 'htmlentities', '~> 4.3.4' # deprecated - only used in Google web search
6563
gem 'html_truncator', '~> 0.4.2'
6664
gem 'addressable', '~> 2.8.0'
6765
gem 'select2-rails', '~> 4.0.3'
@@ -89,7 +87,6 @@ gem 'activerecord-validate_unique_child_attribute', require: 'active_record/vali
8987
gem 'rack-cors', '~> 1.1.0', require: 'rack/cors'
9088
gem 'hashie', '~> 5.0.0'
9189
# retry_block is unsupported - consider replacing with retriable
92-
gem 'retry_block', '~> 1.2.0'
9390
gem 'colorize', '~> 0.8.1'
9491
gem 'http', '~> 5.0'
9592
gem 'robots_tag_parser', '~> 0.1.0'
@@ -118,11 +115,9 @@ gem 'exception_notification', '~> 4.5'
118115
# Temporary fix to remove warnings seen in Rails 7:
119116
# https://github.com/ruby/net-protocol/issues/10
120117
# This gem can be removed once we upgrade to Ruby 3.1.
121-
gem 'net-http'
122118
# Assets-related gems
123119
gem 'coffee-rails', '~> 5.0.0'
124120
gem 'uglifier', '~> 4.2.0'
125-
gem 'compass-blueprint', '~> 1.0.0'
126121
gem 'jquery-ui-rails', '~> 7.0.0'
127122
gem 'jquery-rails', '~> 4.4.0'
128123
gem 'twitter-typeahead-rails', '~> 0.11.1'
@@ -136,8 +131,6 @@ gem 'font-awesome-rails', '~> 4.7.0'
136131
# icons compiled into SVG/CSS+PNG using Grunticon. See
137132
# https://github.com/gsa/font-awesome-grunticon-rails
138133
# for instructions on how to add more icons to this set
139-
gem 'sidekiq', '~> 7.1.3'
140-
gem 'sidekiq-failures', '~> 1.0.0'
141134
gem 'font-awesome-grunticon-rails', git: 'https://github.com/gsa/font-awesome-grunticon-rails', ref: '8ad9734a65f7e2d2de934bebe4ee7b460734f96e'
142135
gem 'react-rails', '~> 3.0.0'
143136
# Locking to prevent a version mismatch between the gem and the NPM package version

Gemfile.lock

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ GEM
270270
launchy
271271
cgi (0.5.0)
272272
chronic (0.10.2)
273-
chunky_png (1.4.0)
274273
cld3 (3.6.0)
275274
climate_control (0.2.0)
276275
coderay (1.1.3)
@@ -284,20 +283,6 @@ GEM
284283
execjs
285284
coffee-script-source (1.12.2)
286285
colorize (0.8.1)
287-
compass (1.0.3)
288-
chunky_png (~> 1.2)
289-
compass-core (~> 1.0.2)
290-
compass-import-once (~> 1.0.5)
291-
rb-fsevent (>= 0.9.3)
292-
rb-inotify (>= 0.9)
293-
sass (>= 3.3.13, < 3.5)
294-
compass-blueprint (1.0.0)
295-
compass
296-
compass-core (1.0.3)
297-
multi_json (~> 1.0)
298-
sass (>= 3.3.0, < 3.5)
299-
compass-import-once (1.0.5)
300-
sass (>= 3.2, < 3.5)
301286
concurrent-ruby (1.3.5)
302287
connection_pool (2.5.3)
303288
counter_culture (2.9.0)
@@ -349,7 +334,6 @@ GEM
349334
cucumber-wire (6.2.1)
350335
cucumber-core (~> 10.1, >= 10.1.0)
351336
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
352-
curb (1.0.9)
353337
database_cleaner (2.1.0)
354338
database_cleaner-active_record (>= 2, < 3)
355339
database_cleaner-active_record (2.2.1)
@@ -552,8 +536,6 @@ GEM
552536
ruby2_keywords (~> 0.0.1)
553537
mutex_m (0.2.0)
554538
mysql2 (0.5.6)
555-
net-http (0.6.0)
556-
uri
557539
net-http-persistent (2.9.4)
558540
net-imap (0.5.9)
559541
date
@@ -671,9 +653,6 @@ GEM
671653
rake (13.0.6)
672654
rash_alt (0.4.12)
673655
hashie (>= 3.4)
674-
rb-fsevent (0.11.2)
675-
rb-inotify (0.11.1)
676-
ffi (~> 1.0)
677656
rdoc (6.14.2)
678657
erb
679658
psych (>= 4.0.0)
@@ -739,7 +718,6 @@ GEM
739718
rspec-expectations (>= 3.0.0)
740719
rspec-mocks (>= 3.0.0)
741720
retriable (3.1.2)
742-
retry_block (1.2.0)
743721
rexml (3.4.1)
744722
robots_tag_parser (0.1.1)
745723
rspec-activemodel-mocks (1.2.1)
@@ -803,7 +781,6 @@ GEM
803781
rubyzip (2.4.1)
804782
rufus-scheduler (3.9.2)
805783
fugit (~> 1.1, >= 1.11.1)
806-
sass (3.4.25)
807784
sass-rails (6.0.0)
808785
sassc-rails (~> 2.1, >= 2.1.1)
809786
sassc (2.4.0)
@@ -834,13 +811,6 @@ GEM
834811
shoulda-matchers (>= 2.1.0)
835812
shoulda-matchers (5.3.0)
836813
activesupport (>= 5.2.0)
837-
sidekiq (7.1.6)
838-
concurrent-ruby (< 2)
839-
connection_pool (>= 2.3.0)
840-
rack (>= 2.2.4)
841-
redis-client (>= 0.14.0)
842-
sidekiq-failures (1.0.4)
843-
sidekiq (>= 4.0.0)
844814
signet (0.20.0)
845815
addressable (~> 2.8)
846816
faraday (>= 0.17.5, < 3.a)
@@ -903,7 +873,6 @@ GEM
903873
unicode-display_width (3.1.4)
904874
unicode-emoji (~> 4.0, >= 4.0.4)
905875
unicode-emoji (4.0.4)
906-
uri (1.0.3)
907876
validate_url (0.2.0)
908877
activemodel (>= 3.0.0)
909878
vcr (6.3.1)
@@ -967,13 +936,11 @@ DEPENDENCIES
967936
cld3 (~> 3.6.0)
968937
coffee-rails (~> 5.0.0)
969938
colorize (~> 0.8.1)
970-
compass-blueprint (~> 1.0.0)
971939
counter_culture (~> 2.9.0)
972940
cssbundling-rails (~> 1.2)
973941
csv (~> 3.3)
974942
cucumber (~> 7.1)
975943
cucumber-rails (~> 2.4)
976-
curb (~> 1.0.1)
977944
database_cleaner (~> 2.0)
978945
debug
979946
dotenv (~> 3.1, >= 3.1.2)
@@ -997,7 +964,6 @@ DEPENDENCIES
997964
haml (~> 6)
998965
hashie (~> 5.0.0)
999966
html_truncator (~> 0.4.2)
1000-
htmlentities (~> 4.3.4)
1001967
http (~> 5.0)
1002968
i18n-tasks (~> 0.9.19)
1003969
iso8601 (~> 0.10.1)
@@ -1011,7 +977,6 @@ DEPENDENCIES
1011977
medusa!
1012978
mutex_m (~> 0.2.0)
1013979
mysql2 (~> 0.5.5)
1014-
net-http
1015980
net-http-persistent (~> 2.9.3)
1016981
newrelic_rpm (~> 9.10)
1017982
nokogiri (~> 1.16)
@@ -1044,7 +1009,6 @@ DEPENDENCIES
10441009
resque-scheduler (~> 4.10.2)
10451010
resque_spec (~> 0.18.0)
10461011
retriable (~> 3.1)
1047-
retry_block (~> 1.2.0)
10481012
robotex!
10491013
robots_tag_parser (~> 0.1.0)
10501014
rspec-activemodel-mocks (~> 1.1)
@@ -1063,8 +1027,6 @@ DEPENDENCIES
10631027
shakapacker (~> 6.5.4)
10641028
shoulda-kept-assign-to (~> 1.1)
10651029
shoulda-matchers (~> 5.0)
1066-
sidekiq (~> 7.1.3)
1067-
sidekiq-failures (~> 1.0.0)
10681030
simplecov (~> 0.17.0)
10691031
truncator (~> 0.1.7)
10701032
turbolinks (~> 5.2.1)

app/engines/search_engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(options = {})
2929
def execute_query
3030
http_params = params
3131
Rails.logger.debug "#{self.class.name} Url: #{api_endpoint}\nParams: #{http_params}"
32-
retry_block(attempts: MAX_ATTEMPT_COUNT, catch: [Faraday::TimeoutError, Faraday::ConnectionFailed]) do |attempt|
32+
Retriable.retriable(tries: MAX_ATTEMPT_COUNT, on: [Faraday::TimeoutError, Faraday::ConnectionFailed]) do |attempt|
3333
reset_timer
3434
@cached_response = api_connection.get(api_endpoint, http_params)
3535
process_cached_response(attempt)

app/models/affiliate.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'digest'
4-
require 'sass/css'
4+
55

66
class Affiliate < ApplicationRecord
77
extend HumanAttributeName
@@ -175,7 +175,7 @@ class Affiliate < ApplicationRecord
175175
validates :secondary_header_links, length: { maximum: 3 }
176176

177177
after_validation :update_error_keys
178-
before_save :set_css_properties, :generate_look_and_feel_css, :set_json_fields, :set_search_labels
178+
before_save :set_css_properties, :set_json_fields, :set_search_labels
179179
before_update :clear_existing_attachments
180180
after_commit :normalize_site_domains, on: :create
181181
after_commit :remove_boosted_contents_from_index, on: :destroy
@@ -304,7 +304,6 @@ def indexing_locale
304304
managed_footer_links
305305
external_tracking_code
306306
submitted_external_tracking_code
307-
mobile_look_and_feel_css
308307
logo_alt_text
309308
header_tagline
310309
header_tagline_url
@@ -713,10 +712,7 @@ def set_api_access_key
713712
self.api_access_key = Digest::SHA256.base64digest("#{name}:#{Time.current.to_i}:#{rand}").tr('+/', '-_')
714713
end
715714

716-
def generate_look_and_feel_css
717-
renderer = AffiliateCss.new(build_css_hash)
718-
self.mobile_look_and_feel_css = renderer.render_mobile_css
719-
end
715+
720716

721717
def build_css_hash
722718
css_hash = {}

app/views/layouts/searches.html.haml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
= font_stylesheet_link_tag @search.affiliate
2121
= stylesheet_link_tag 'searches'
22-
/[if IE]
23-
= stylesheet_link_tag 'searches_mobile_ie'
24-
! <style>#{@search.affiliate.mobile_look_and_feel_css}</style>
2522
/[if lt IE 9]
2623
= stylesheet_link_tag 'searches_mobile_ie_lt9'
2724
= javascript_include_tag 'searches_ie_lt9'

config/initializers/sidekiq.rb

Lines changed: 0 additions & 11 deletions
This file was deleted.

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
mount Resque::Server.new, at: '/resque', constraints: AffiliateAdminConstraint
280280
get '/resque/(*all)', to: redirect(path: '/login')
281281

282-
mount Sidekiq::Web => '/sidekiq', constraints: AffiliateAdminConstraint
282+
283283
end
284284

285285
match '/admin/affiliates/:id/analytics' => 'admin/affiliates#analytics', :as => :affiliate_analytics_redirect, via: :get

lib/document_fetcher.rb

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@ module DocumentFetcher
33

44
# Caveat fetcher: These requests cannot be recorded by VCR:
55
# https://cm-jira.usa.gov/browse/SRCH-645
6-
def self.fetch(url, connect_timeout: 2, read_timeout: 8)
7-
easy = Curl::Easy.new(url) do |c|
8-
c.connect_timeout = connect_timeout
9-
c.follow_location = true
10-
c.max_redirects = DEFAULT_MAX_REDIRECTS
11-
c.timeout = read_timeout
12-
c.useragent = DEFAULT_USER_AGENT
13-
c.on_success { return handle_success_or_redirect easy }
14-
c.on_redirect { return handle_success_or_redirect easy }
6+
def self.fetch(url, connect_timeout: 2, read_timeout: 8, limit: DEFAULT_MAX_REDIRECTS)
7+
raise ArgumentError, 'Too many redirects' if limit.zero?
8+
9+
uri = URI.parse(url)
10+
http = Net::HTTP.new(uri.host, uri.port)
11+
http.use_ssl = (uri.scheme == 'https')
12+
http.open_timeout = connect_timeout
13+
http.read_timeout = read_timeout
14+
request = Net::HTTP::Get.new(uri.request_uri)
15+
request['User-Agent'] = DEFAULT_USER_AGENT
16+
response = http.request(request)
17+
18+
case response
19+
when Net::HTTPSuccess
20+
{ status: response.code, body: response.body, last_effective_url: uri.to_s }
21+
when Net::HTTPRedirection
22+
fetch(response['location'], connect_timeout: connect_timeout, read_timeout: read_timeout, limit: limit - 1)
23+
else
24+
{ error: "#{response.code} #{response.message}" }
1525
end
16-
easy.perform
17-
{ error: "Unable to fetch #{url}" }
1826
rescue => e
1927
Rails.logger.error "#{self.name} fetch error url: #{url}", e
2028
{ error: e.message }
2129
end
2230

2331
private
2432

25-
def self.handle_success_or_redirect(easy)
26-
{ body: easy.body,
27-
last_effective_url: easy.last_effective_url,
28-
status: easy.status }
29-
end
33+
3034
end

lib/renderers/affiliate_css.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)