Skip to content

Commit

Permalink
Merge pull request #198 from sanger/GPL576-deprecate-lighthouse-sampl…
Browse files Browse the repository at this point in the history
…e-creation-in-ss

GPL576 - Removed API call to lighthouse from Asset Audits on receiving plates
  • Loading branch information
andrewsparkes authored Jul 23, 2020
2 parents 4639157 + db85191 commit 74139b8
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 143 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Sequencescape.
* [Sequencescape](https://github.com/sanger/sequencescape/) is required to authenticate against
* [wrangler](https://github.com/sanger/wrangler/) is required if you want automatic sample creation
in Sequencescape when tube racks are scanned in
* [lighthouse](https://github.com/sanger/lighthouse) is required for automatic sample creation in
Sequencescape for plates received from the Lighthouse Labs

## Getting started

Expand Down
18 changes: 4 additions & 14 deletions app/controllers/process_plates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class ProcessPlatesController < ApplicationController
require 'wrangler'
require 'lighthouse'

skip_before_action :configure_api, except: [:create]

Expand Down Expand Up @@ -61,17 +60,12 @@ def receive_plates_process?(params)
@receive_plates_process ||= InstrumentProcess.find_by(id: params[:instrument_process]).key.eql?('slf_receive_plates')
end

# Call any external services - currently lighthouse service for plates from Lighthouse Labs and
# wrangler for tube racks. If no samples are found in the lighthouse service, try the wrangler
# Call any external services - currently wrangler for tube racks.
def call_external_services(barcodes)
output = { lighthouse: [], wrangler: [] }
# call the lighthouse service first as we are assuming that most labware scanned will be
# plates from Lighthouse Labs
output[:lighthouse] = Lighthouse.call_api(barcodes)
output = { wrangler: [] }

# keeping it simple for now, if all the responses are not CREATED, send ALL the barcodes
# to the wrangler
output[:wrangler] = Wrangler.call_api(barcodes) unless all_created?(output[:lighthouse])
# Send all the barcodes to the wrangler
output[:wrangler] = Wrangler.call_api(barcodes)

output
end
Expand All @@ -94,10 +88,6 @@ def generate_results(barcodes, responses)
barcodes.each { |b| output[b] = { success: 'No' } }

# loop through service responses to update 'output' with successes
# puts "DEBUG: responses: #{JSON.pretty_generate(responses)}"
responses[:lighthouse]&.select { |r| r[:code] == '201' }&.each do |r|
output[r[:barcode]] = parse_response(r, :Lighthouse)
end
responses[:wrangler]&.select { |r| r[:code] == '201' }&.each do |r|
output[r[:barcode]] = parse_response(r, :CGaP)
end
Expand Down
3 changes: 0 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
# https://github.com/sanger/wrangler
config.wrangler_url = 'http://127.0.0.1:5000/wrangle'

# https://github.com/sanger/lighthouse
config.lighthouse_host = 'http://127.0.0.1:5000'

# config.logger.broadcast_messages = false

# Use an evented file watcher to asynchronously detect changes in source code,
Expand Down
3 changes: 0 additions & 3 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,4 @@

# https://github.com/sanger/wrangler
config.wrangler_url = 'http://example.com/wrangle'

# https://github.com/sanger/lighthouse
config.lighthouse_host = 'http://127.0.0.1:5000'
end
40 changes: 0 additions & 40 deletions lib/lighthouse.rb

This file was deleted.

28 changes: 5 additions & 23 deletions test/controllers/process_plates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'test_helper'
require 'lighthouse'
require 'wrangler'

class ProcessPlatesControllerTest < ActiveSupport::TestCase
Expand All @@ -20,29 +19,17 @@ class ProcessPlatesControllerTest < ActiveSupport::TestCase
assert_equal(ProcessPlatesController.new.all_created?([{ code: '201' }, { code: '200' }]), false)
end

should 'call external services 1' do
Lighthouse.expects(:call_api).with(%w[123 456]).returns([])
should 'call external services' do
Wrangler.expects(:call_api).with(%w[123 456])
ProcessPlatesController.new.call_external_services(%w[123 456])
end

should 'call external services 2' do
Lighthouse.expects(:call_api).with(%w[123 456]).returns([{ code: 400 }])
Wrangler.expects(:call_api).with(%w[123 456])
ProcessPlatesController.new.call_external_services(%w[123 456])
end

should 'call only lighthouse service' do
Lighthouse.expects(:call_api).returns([{ code: '201' }])
ProcessPlatesController.new.call_external_services(%w[123 456])
end
end

context '#generate_results' do
should 'give failed results if no response' do
barcodes = ['AB1']

responses = { lighthouse: [], wrangler: [] }
responses = { wrangler: [] }

expected_results = { 'AB1' => { success: 'No' } }

Expand All @@ -54,28 +41,23 @@ class ProcessPlatesControllerTest < ActiveSupport::TestCase
barcodes = %w[AB1 AB2 AB3]

responses = {
lighthouse: [
wrangler: [
generate_success_response('AB1', 'Purpose 1', ['Study 1', 'Study 2']),
generate_success_response('AB2', 'Purpose 1', ['Study 1']),
generate_fail_response('AB3')
],
wrangler: [
generate_fail_response('AB1'),
generate_fail_response('AB2'),
generate_success_response('AB3', 'Purpose 1', ['Study 1', 'Study 2'])
]
}

expected_results = {
'AB1' => {
success: 'Yes',
source: :Lighthouse,
source: :CGaP,
purpose: 'Purpose 1',
study: 'Study 1, Study 2'
},
'AB2' => {
success: 'Yes',
source: :Lighthouse,
source: :CGaP,
purpose: 'Purpose 1',
study: 'Study 1'
},
Expand Down
58 changes: 0 additions & 58 deletions test/unit/lighthouse_test.rb

This file was deleted.

0 comments on commit 74139b8

Please sign in to comment.