From a6d256c1c27a707238526356b435ff9db15f6f9d Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 14 May 2020 07:46:09 -0500 Subject: [PATCH] Remove Indexer backlog from header Ref https://github.com/sul-dlss/argo/issues/924#issuecomment-628336154 --- app/controllers/index_queue_controller.rb | 9 ---- app/javascript/modules/index_queue.js | 28 ---------- app/javascript/packs/application.js | 7 --- app/javascript/style/application.scss | 1 - app/javascript/style/index_queue.scss | 3 -- app/models/argo/exceptions.rb | 5 -- app/models/index_queue.rb | 36 ------------- app/views/_user_util_links.html.erb | 7 --- config/routes.rb | 2 - .../index_queue_controller_spec.rb | 19 ------- spec/features/indexer_backlog_spec.rb | 25 --------- spec/models/index_queue_spec.rb | 54 ------------------- spec/support/mock_index_depth.rb | 9 ---- 13 files changed, 205 deletions(-) delete mode 100644 app/controllers/index_queue_controller.rb delete mode 100644 app/javascript/modules/index_queue.js delete mode 100644 app/javascript/style/index_queue.scss delete mode 100644 app/models/index_queue.rb delete mode 100644 spec/controllers/index_queue_controller_spec.rb delete mode 100644 spec/features/indexer_backlog_spec.rb delete mode 100644 spec/models/index_queue_spec.rb delete mode 100644 spec/support/mock_index_depth.rb diff --git a/app/controllers/index_queue_controller.rb b/app/controllers/index_queue_controller.rb deleted file mode 100644 index fd5c1a96c5..0000000000 --- a/app/controllers/index_queue_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class IndexQueueController < ApplicationController - ## - # Client side access to the index queue depth - def depth - render json: IndexQueue.new.depth.to_json, layout: false - end -end diff --git a/app/javascript/modules/index_queue.js b/app/javascript/modules/index_queue.js deleted file mode 100644 index c2d8a806c2..0000000000 --- a/app/javascript/modules/index_queue.js +++ /dev/null @@ -1,28 +0,0 @@ -/*global Blacklight */ -'use strict'; - -(function($) { - /* - jQuery plugin that requests and displays Index Queue Depth - */ - - $.fn.indexQueueDepth = function() { - return this.each(function() { - var $el = $(this); - var url = $el.data('index-queue-depth-url'); - $.getJSON(url) - .done(function(data) { - if (data > 1000) { - $el.parent().addClass('text-warning'); - } - switch(data) { - case null: - $el.text('-'); - break; - default: - $el.text(data); - } - }); - }); - }; -})(jQuery); diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 940178205e..75d6711efe 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -25,7 +25,6 @@ import 'modules/apo_form' import 'modules/button_checker' import 'modules/datastream_edit' import 'modules/date_range_query' -import 'modules/index_queue' import ItemCollection from 'modules/item_collection' import 'modules/permission_add' import 'modules/permission_grant' @@ -71,12 +70,6 @@ Blacklight.onLoad(function() { // $('[data-datepicker]').datepicker() }) - -Blacklight.onLoad(function() { - $('[data-index-queue-depth-url]').indexQueueDepth() -}) - - Blacklight.onLoad(function() { new ItemCollection().initialize() }) diff --git a/app/javascript/style/application.scss b/app/javascript/style/application.scss index d060561cb6..a720183fc6 100644 --- a/app/javascript/style/application.scss +++ b/app/javascript/style/application.scss @@ -15,7 +15,6 @@ $logo-image: "../images/logo.png"; @import "document"; @import "embargo"; @import "icons"; -@import "index_queue"; @import "profile"; @import "search_results"; @import "show"; diff --git a/app/javascript/style/index_queue.scss b/app/javascript/style/index_queue.scss deleted file mode 100644 index 82e5b67250..0000000000 --- a/app/javascript/style/index_queue.scss +++ /dev/null @@ -1,3 +0,0 @@ -.navbar-text.text-warning { - font-weight: bold; -} diff --git a/app/models/argo/exceptions.rb b/app/models/argo/exceptions.rb index 695ef0aa35..9d03d83da3 100644 --- a/app/models/argo/exceptions.rb +++ b/app/models/argo/exceptions.rb @@ -2,11 +2,6 @@ module Argo module Exceptions - class IndexQueueRequestFailed < StandardError - end - class IndexQueueInvalidResponse < StandardError - end - # Raised if there is a problem communicating with dor_indexing_app class ReindexError < RuntimeError; end end diff --git a/app/models/index_queue.rb b/app/models/index_queue.rb deleted file mode 100644 index 5049a44d23..0000000000 --- a/app/models/index_queue.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Requests the depth of the index queue in dor_indexing_app -class IndexQueue - ## - # Gets the depth of the index queue - # @return [Integer, nil] - def depth - parsed_response - rescue Argo::Exceptions::IndexQueueInvalidResponse, Argo::Exceptions::IndexQueueRequestFailed => e - Honeybadger.notify(e) - nil - end - - private - - ## - # @return [String] the path to the queue depth endpoint on dor_indexing_app - def url - Settings.status_indexer_url - end - - def parsed_response - JSON.parse(response)['value'] - rescue JSON::ParserError, TypeError, NoMethodError - raise Argo::Exceptions::IndexQueueInvalidResponse, - "Could not parse the response from #{url} as JSON" - end - - def response - Faraday.get(url).body - rescue SocketError, Faraday::Error - raise Argo::Exceptions::IndexQueueRequestFailed, - "Request to index queue at #{url} failed" - end -end diff --git a/app/views/_user_util_links.html.erb b/app/views/_user_util_links.html.erb index b4d0772542..7032a02b38 100644 --- a/app/views/_user_util_links.html.erb +++ b/app/views/_user_util_links.html.erb @@ -64,12 +64,5 @@
  • <%= link_to 'Feedback', 'mailto:argo-feedback@lists.stanford.edu' %>
  • - -
  • - -
  • - diff --git a/config/routes.rb b/config/routes.rb index 150af8f275..f8943f3c3e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -178,8 +178,6 @@ resources :objects, only: :create # we only implement create for object registration end - get 'index_queue/depth', to: 'index_queue#depth' - namespace :workflow_service do get '/:pid/closeable', action: 'closeable', diff --git a/spec/controllers/index_queue_controller_spec.rb b/spec/controllers/index_queue_controller_spec.rb deleted file mode 100644 index 076b914697..0000000000 --- a/spec/controllers/index_queue_controller_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe IndexQueueController do - describe 'GET depth' do - before do - sign_in create(:user) - end - - let(:index_queue) { double('index_queue', depth: 100) } - - it 'returns a depth from the IndexQueue class' do - expect(IndexQueue).to receive(:new).and_return(index_queue) - get :depth, params: { format: :json } - expect(response.body).to eq '100' - end - end -end diff --git a/spec/features/indexer_backlog_spec.rb b/spec/features/indexer_backlog_spec.rb deleted file mode 100644 index d69eb4cb4d..0000000000 --- a/spec/features/indexer_backlog_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'Indexer Backlog status', js: true do - before do - sign_in create(:user), groups: ['sdr:administrator-role'] - end - - it 'displays hyphen when not reachable' do - visit root_path - expect(page).to have_css 'li p.navbar-text', text: 'Indexer Backlog: -' - end - it 'displays count when response is integer' do - expect_any_instance_of(IndexQueue).to receive(:depth).and_return 100 - visit root_path - expect(page).to have_css 'li p.navbar-text', text: 'Indexer Backlog: 100' - end - it 'adds text-warning class when greater than 1000' do - expect_any_instance_of(IndexQueue).to receive(:depth).and_return 1001 - visit root_path - expect(page).to have_css 'li p.navbar-text', text: 'Indexer Backlog: 1001' - expect(page).to have_css '.text-warning', text: '1001' - end -end diff --git a/spec/models/index_queue_spec.rb b/spec/models/index_queue_spec.rb deleted file mode 100644 index ac0eeb44f1..0000000000 --- a/spec/models/index_queue_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe IndexQueue do - subject { described_class.new } - - let(:good_response) { { value: 100 }.to_json } - - describe '#depth' do - describe 'when response fails' do - it 'with SocketError' do - expect(Faraday).to receive(:get).and_raise(SocketError) - expect(subject.depth).to be_nil - end - end - - describe 'when response is not JSON' do - it 'cannot be parsed' do - expect(subject).to receive(:response).and_return 'not JSON' - expect(subject.depth).to be_nil - end - end - - describe 'when response is nil' do - it 'cannot be parsed' do - expect(subject).to receive(:response).and_return nil - expect(subject.depth).to be_nil - end - end - - describe 'when response is not string' do - it 'cannot be parsed' do - expect(subject).to receive(:response).and_return [] - expect(subject.depth).to be_nil - end - end - - describe 'when response is not expected JSON' do - it 'cannot be parsed' do - expect(subject).to receive(:response) - .and_return({ test: 'test' }.to_json) - expect(subject.depth).to be_nil - end - end - - describe 'with expected response' do - it 'returns response integer' do - expect(subject).to receive(:response).and_return good_response - expect(subject.depth).to eq 100 - end - end - end -end diff --git a/spec/support/mock_index_depth.rb b/spec/support/mock_index_depth.rb deleted file mode 100644 index 7f83ca999a..0000000000 --- a/spec/support/mock_index_depth.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -RSpec.configure do |config| - config.before(:example, type: :feature) do - # This stubs out the call that IndexQueue makes - stub_request(:get, 'https://dor-indexing-app:3000/dor/queue_size.json') - .to_return(status: 200, body: '1', headers: {}) - end -end