Skip to content

Commit

Permalink
removed references to wrangler.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieing committed Mar 8, 2021
1 parent af598a4 commit 3fb76ca
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 225 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ tmp/**/*

# created by the byebug gem
.byebug_history

coverage
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Sequencescape.
### Running applications

* [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

## Getting started

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

skip_before_action :configure_api, except: [:create]

Expand Down Expand Up @@ -36,9 +35,6 @@ def create
# 20 barcodes takes about 2 mins as of 2020-06-22. This limit is to prevent the request timing out.
raise "Please scan #{ProcessPlate::RECEIVE_PLATES_MAX} barcodes or fewer" if barcodes.count > ProcessPlate::RECEIVE_PLATES_MAX

responses = call_external_services(barcodes)
@results = generate_results(barcodes, responses)

flash[:notice] = "Scanned #{bed_layout_verification.process_plate&.num_unique_barcodes} barcodes."
render :results
rescue StandardError => e
Expand All @@ -60,50 +56,11 @@ 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 wrangler for tube racks.
def call_external_services(barcodes)
output = { wrangler: [] }

# Send all the barcodes to the wrangler
output[:wrangler] = Wrangler.call_api(barcodes)

output
end

# Returns a list of unique barcodes by removing blanks and duplicates
def sanitize_barcodes(barcodes)
barcodes.split(/\s+/).reject(&:blank?).compact.uniq
end

# Checks a list of responses if they are all CREATED (201)
def all_created?(responses)
return false if responses.empty?

responses.all? { |response| response[:code] == '201' }
end

def generate_results(barcodes, responses)
output = {}
# default 'success' for each barcode to 'No'
barcodes.each { |b| output[b] = { success: 'No' } }

# loop through service responses to update 'output' with successes
responses[:wrangler]&.select { |r| r[:code] == '201' }&.each do |r|
output[r[:barcode]] = parse_response(r, :CGaP)
end

output
end

def parse_response(response, service)
{
success: 'Yes',
source: service,
purpose: response.dig(:body, 'data', 'attributes', 'purpose_name'),
study: response.dig(:body, 'data', 'attributes', 'study_names')&.join(', ')
}
end

def all_labware_created?(results)
return false if results.any? { |_barcode, details| details[:success] == 'No' }

Expand Down
3 changes: 0 additions & 3 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@

config.admin_email = '[email protected]'

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

# config.logger.broadcast_messages = false

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

config.admin_email = '[email protected]'

# https://github.com/sanger/wrangler
config.wrangler_url = 'http://example.com/wrangle'
end
41 changes: 0 additions & 41 deletions lib/wrangler.rb

This file was deleted.

75 changes: 0 additions & 75 deletions test/controllers/process_plates_controller.rb

This file was deleted.

16 changes: 16 additions & 0 deletions test/controllers/process_plates_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require 'test_helper'

class ProcessPlatesControllerTest < ActiveSupport::TestCase
context 'while testing public functions' do
should 'sanitize barcodes' do
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 456'), %w[123 456])
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 456'), %w[123 456])
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 123 456'), %w[123 456])
assert_equal(ProcessPlatesController.new.sanitize_barcodes("123\n456"), %w[123 456])
end

end

end
59 changes: 0 additions & 59 deletions test/unit/wrangler_test.rb

This file was deleted.

0 comments on commit 3fb76ca

Please sign in to comment.