Skip to content

Commit

Permalink
Merge branch 'y24-088-tuberacks-epic' into y24-486-relatives-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHulme committed Jan 17, 2025
2 parents 808f001 + db9b440 commit 37d98e9
Show file tree
Hide file tree
Showing 192 changed files with 3,320 additions and 3,667 deletions.
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.64.3
3.66.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ FactoryBot.define do
transient { related_thing { create :v2_tag_group_with_tags } }

after(:build) do |record, factory|
record._cached_relationship(:related_thing) { factory.related_thing } if evaluator.related_thing
record._cached_relationship(:related_thing) { factory.related_thing } if factory.related_thing
end
end
end
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/labware_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ def state_changer_for(purpose_uuid, labware_uuid)
end

def presenter_for(labware)
presenter = Presenters.lookup_for(labware).new(labware:)

# TODO: {Y24-190} - Remove this line when the API v1 is removed from Presenters::ExtendedCsv
presenter.api = api if presenter.respond_to?(:api=)

presenter
Presenters.lookup_for(labware).new(labware:)
end
end
19 changes: 13 additions & 6 deletions app/controllers/qc_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ class QcFilesController < ApplicationController
before_action :find_assets, only: %i[create index]

def index
respond_to { |format| format.json { render json: { 'qc_files' => asset.qc_files } } }
respond_to { |format| format.json { render json: { 'qc_files' => asset.qc_files.map { |q| qc_file_to_json(q) } } } }
end

def show
response = api.qc_file.find(params[:id]).retrieve
filename = /filename="([^"]*)"/.match(response['Content-Disposition'])[1] || 'unnamed_file'
send_data(response.body, filename: filename, type: 'sequencescape/qc_file')
qc_file = Sequencescape::Api::V2::QcFile.find(uuid: params[:id]).first
send_data(qc_file.contents, filename: qc_file.filename, type: 'sequencescape/qc_file')
end

def create
asset.qc_files.create_from_file!(params['qc_file'], params['qc_file'].original_filename)
Sequencescape::Api::V2::QcFile.create_for_labware!(
contents: params['qc_file'].read,
filename: params['qc_file'].original_filename,
labware: asset
)
redirect_to(
asset_path,
notice: 'Your file has been uploaded and is available from the file tab' # rubocop:todo Rails/I18nLocaleTexts
Expand All @@ -30,12 +33,16 @@ def create

private

def qc_file_to_json(qc_file)
{ filename: qc_file.filename, size: qc_file.size, uuid: qc_file.uuid, created: qc_file.created_at.to_fs(:long) }
end

def find_assets
%w[plate tube multiplexed_library_tube tube_rack].each do |klass|
next if params["limber_#{klass}_id"].nil?

@asset_path = send(:"limber_#{klass}_path", params["limber_#{klass}_id"])
@asset = api.send(:"#{klass}").find(params["limber_#{klass}_id"])
@asset = Sequencescape::Api::V2::Labware.find(uuid: params["limber_#{klass}_id"]).first
return true
end
false
Expand Down
54 changes: 54 additions & 0 deletions app/controllers/tube_racks/tube_racks_exports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

require 'csv'

# The exports controller handles the generation of exported files for tube racks
class TubeRacks::TubeRacksExportsController < ApplicationController
include ExportsFilenameBehaviour
# helper ExportsHelper
before_action :locate_labware, only: :show
rescue_from Export::NotFound, with: :not_found

def show
@page = params.fetch(:page, 0).to_i
@workflow = export.workflow

# Set the filename for the export via the ExportsFilenameBehaviour concern
set_filename(@labware, @page) if export.filename

render export.csv
end

private

def export
@export ||= Export.find(params[:id])
end

def not_found
raise ActionController::RoutingError, "Unknown template #{params[:id]}"
end

def configure_api
# We don't use the V1 Sequencescape API here, so lets disable its initialization.
# Probably should consider two controller classes as this expands.
end

def locate_labware
@labware =
@tube_rack =
Sequencescape::Api::V2.tube_rack_with_custom_includes(
include_parameters,
select_parameters,
uuid: params[:limber_tube_rack_id]
)
end

def include_parameters
export.tube_rack_includes || nil
end

def select_parameters
export.tube_rack_selects || nil
end
end
2 changes: 1 addition & 1 deletion app/controllers/tubes/work_completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class Tubes::WorkCompletionsController < ApplicationController
before_action :check_for_current_user!

def labware
@labware ||= api.tube.find(params[:limber_tube_id])
@labware ||= Sequencescape::Api::V2.tube_for_completion(params[:limber_tube_id])
end
end
Loading

0 comments on commit 37d98e9

Please sign in to comment.