-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 4133-y24-120-bug-taken-link-error-when-cr…
…eating-sequencing-batches
- Loading branch information
Showing
33 changed files
with
387 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON API controller for RequestMetadata | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation | ||
class RequestMetadataController < JSONAPI::ResourceController | ||
# By default JSONAPI::ResourceController provides most the standard | ||
# behaviour, and in many cases this file may be left empty. | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
# A class for customer requests that need the extra metadata fields used for PBMC pooling calculations | ||
class PbmcPoolingCustomerRequest < CustomerRequest | ||
has_metadata as: Request do | ||
custom_attribute(:number_of_samples_per_pool, integer: true, required: false, default: nil) | ||
custom_attribute(:cells_per_chip_well, integer: true, required: false, default: nil) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# @todo This documentation does not yet include a detailed description of what this resource represents. | ||
# @todo This documentation does not yet include detailed descriptions for relationships, attributes and filters. | ||
# @todo This documentation does not yet include any example usage of the API via cURL or similar. | ||
# | ||
# @note Access this resource via the `/api/v2/requests_metadata/` endpoint. | ||
# | ||
# Provides a JSON:API representation of {Request::Metadata}. | ||
# | ||
# For more information about JSON:API see the [JSON:API Specifications](https://jsonapi.org/format/) | ||
# or look at the [JSONAPI::Resources](http://jsonapi-resources.com/) package for Sequencescape's implementation | ||
# of the JSON:API standard. | ||
class RequestMetadataResource < BaseResource | ||
# NB. request_metadata has been added to config/initializers/inflections.rb to make this class name | ||
# work otherwise it expects RequestMetadatumResource | ||
|
||
# Sets add_model_hint true by default, this allows updates from Limber, otherwise get a | ||
# 500 error as it looks for resource Api::V2::MetadatumResource | ||
model_name 'Request::Metadata' | ||
|
||
# Associations: | ||
has_one :request | ||
|
||
### | ||
# Attributes | ||
### | ||
|
||
# @!attribute [r] number_of_samples_per_pool | ||
# @return [Int] the number_of_samples_per_pool. | ||
attribute :number_of_samples_per_pool, readonly: true | ||
|
||
# @!attribute [r] cells_per_chip_well | ||
# @return [Int] the cells_per_chip_well. | ||
attribute :cells_per_chip_well, readonly: true | ||
|
||
# Filters | ||
|
||
# Custom methods | ||
# These shouldn't be used for business logic, and a more about | ||
# I/O and isolating implementation details. | ||
|
||
# Class method overrides | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
db/migrate/20240917133813_addsc_rna_fields_to_request_metadata.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
class AddscRnaFieldsToRequestMetadata < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :request_metadata, :number_of_samples_per_pool, :integer, null: true | ||
add_column :request_metadata, :cells_per_chip_well, :integer, null: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
# Run the rake task with the following command: | ||
# bundle exec rake number_of_samples_per_pool:populate[20,1] | ||
# The rake task will populate the number of samples per pool column in the request_metadata table | ||
# for a given submission ID. | ||
namespace :number_of_samples_per_pool do | ||
desc 'Populate number of samples per pool column in request_metadata table for a given submission ID' | ||
|
||
task :populate, %i[samples_per_pool submission_id] => :environment do |_, args| | ||
args.with_defaults(samples_per_pool: nil, submission_id: nil) | ||
|
||
raise StandardError, 'Number of samples per pool is missing' if args[:samples_per_pool].nil? | ||
raise StandardError, 'Submission ID is missing' if args[:submission_id].nil? | ||
|
||
puts "Populating number of samples per pool column with #{args[:samples_per_pool]} | ||
in request_metadata table for submission: #{args[:submission_id]}..." | ||
|
||
ActiveRecord::Base.transaction do | ||
saved_count = 0 | ||
Request::Metadata | ||
.joins(:request) | ||
.where(requests: { submission_id: args[:submission_id] }) | ||
.find_each(batch_size: 50) do |request_metadata| | ||
puts "Processing request_metadata #{request_metadata.id}..." | ||
saved_count = process_request_metadata(request_metadata, saved_count, args[:samples_per_pool]) | ||
end | ||
end | ||
end | ||
|
||
def process_request_metadata(request_metadata, saved_count, samples_per_pool) | ||
request_metadata.number_of_samples_per_pool = samples_per_pool | ||
begin | ||
request_metadata.save! | ||
saved_count += 1 | ||
rescue ActiveRecord::ActiveRecordError, StandardError => e | ||
puts "Error processing request_metadata #{request_metadata.id}: #{e.message}" | ||
raise e | ||
end | ||
saved_count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.