-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Y24-190-3: Support Limber with BulkTransfers on v2 API #4425
Open
sdjmchattie
wants to merge
15
commits into
develop-Y24-190
Choose a base branch
from
Y24-190-support-limber-with-bulk-transfers-on-v2-api
base: develop-Y24-190
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6b605c9
Fix pluralisation of tube_from_tube_creations endpoint in documentation
sdjmchattie 57461b6
Tidy up BulkTransfer model
sdjmchattie 390a90b
Implement the BulkTransfer resource and controller
sdjmchattie 8db4003
Fix pluralisation of tube_from_tube_creations endpoint in documentation
sdjmchattie b7ae240
Tidy up BulkTransfer model
sdjmchattie 4f9f35a
Implement the BulkTransfer resource and controller
sdjmchattie a401ec9
Merge branch 'Y24-190-support-limber-with-bulk-transfers-on-v2-api' o…
sdjmchattie 045c991
Use attribute options for BulkTransferResource
sdjmchattie af4a39b
Add test for BulkTransferResource
sdjmchattie f153618
Add a BulkTransfer factory
sdjmchattie a211847
Create tests for the bulk_transfer requests
sdjmchattie 3782fb4
Merge branch 'develop-Y24-190' into Y24-190-support-limber-with-bulk-…
sdjmchattie e78b99f
Apply Rubocop and linting rules
sdjmchattie 8438179
Update devour rake task to only work on resources
sdjmchattie 0556504
Merge branch 'develop-Y24-190' into Y24-190-support-limber-with-bulk-…
sdjmchattie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Bulk Transfers. | ||
# See: http://jsonapi-resources.com/ for JSONAPI::Resource documentation. | ||
class BulkTransfersController < 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V2 | ||
# Provides a JSON:API representation of {BulkTransfer} which allows the transfer of multiple wells from source | ||
# plates to destination plates. The plates and wells to transfer are specified in the {#well_transfers} attribute. | ||
# Creation of this resource via a `POST` request will perform the specified transfers. | ||
# After creation, the transfers can be accessed via the {#transfers} relationship. | ||
# | ||
# @note This resource cannot be modified after creation: its endpoint will not accept `PATCH` requests. | ||
# @note Access this resource via the `/api/v2/bulk_transfers/` endpoint. | ||
# | ||
# @example POST request | ||
# POST /api/v2/bulk_transfers/ | ||
# { | ||
# "data": { | ||
# "type": "bulk_transfers", | ||
# "attributes": { | ||
# "well_transfers": [ | ||
# { | ||
# "source_uuid": "src_plate1_uuid", | ||
# "source_location": "A1", | ||
# "destination_uuid": "dest_plate1_uuid", | ||
# "destination_location": "A1" | ||
# }, | ||
# { | ||
# "source_uuid": "src_plate1_uuid", | ||
# "source_location": "B1", | ||
# "destination_uuid": "dest_plate2_uuid", | ||
# "destination_location": "A1" | ||
# }, | ||
# { | ||
# "source_uuid": "src_plate2_uuid", | ||
# "source_location": "A1", | ||
# "destination_uuid": "dest_plate1_uuid", | ||
# "destination_location": "B1" | ||
# }, | ||
# { | ||
# "source_uuid": "src_plate2_uuid", | ||
# "source_location": "B1", | ||
# "destination_uuid": "dest_plate2_uuid", | ||
# "destination_location": "B1" | ||
# } | ||
# ], | ||
# "user_uuid": "user_uuid" | ||
# } | ||
# } | ||
# } | ||
# | ||
# @example GET request for all BulkTransfer resources | ||
# GET /api/v2/bulk_transfers/ | ||
# | ||
# @example GET request for a BulkTransfer with ID 123 | ||
# GET /api/v2/bulk_transfers/123/ | ||
# | ||
# 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 BulkTransferResource < BaseResource | ||
### | ||
# Attributes | ||
### | ||
|
||
# @!attribute [w] user_uuid | ||
# This is declared for convenience where the user is not available to set as a relationship. | ||
# Setting this attribute alongside the `user` relationship will prefer the relationship value. | ||
# @deprecated Use the `user` relationship instead. | ||
# @param value [String] The UUID of the user who initiated the creation of the bulk transfers. | ||
# @return [Void] | ||
# @see #user | ||
attribute :user_uuid, writeonly: true | ||
|
||
def user_uuid=(value) | ||
@model.user = User.with_uuid(value).first | ||
end | ||
|
||
# @!attribute [r] uuid | ||
# @return [String] The UUID of the bulk transfers operation. | ||
attribute :uuid, readonly: true | ||
|
||
# @!attribute [w] well_transfers | ||
# An array of well transfers to perform. Each transfer is a hash with the following: | ||
# - `source_uuid` [String] The UUID of the source plate. | ||
# - `source_location` [String] The location on the source plate. | ||
# - `destination_uuid` [String] The UUID of the destination plate. | ||
# - `destination_location` [String] The location on the destination plate. | ||
# @return [Void] | ||
attribute :well_transfers, writeonly: true | ||
|
||
### | ||
# Relationships | ||
### | ||
|
||
# @!attribute [r] transfers | ||
# The transfers that were created as a result of this bulk transfer. | ||
# @return [Array<TransferResource>] An array of created transfers. | ||
has_many :transfers, readonly: true | ||
|
||
# @!attribute [rw] user | ||
# Setting this relationship alongside the `user_uuid` attribute will override the attribute value. | ||
# @return [UserResource] The user who initiated the creation of the bulk transfers. | ||
# @note This relationship is required. | ||
has_one :user | ||
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,40 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :bulk_transfer do | ||
transient do | ||
source_plates { create_list(:plate, 2) } | ||
destination_plates { create_list(:plate, 2) } | ||
end | ||
|
||
user | ||
well_transfers do | ||
[ | ||
{ | ||
'source_uuid' => source_plates[0].uuid, | ||
'source_location' => 'A1', | ||
'destination_uuid' => destination_plates[0].uuid, | ||
'destination_location' => 'A1' | ||
}, | ||
{ | ||
'source_uuid' => source_plates[0].uuid, | ||
'source_location' => 'B1', | ||
'destination_uuid' => destination_plates[1].uuid, | ||
'destination_location' => 'A1' | ||
}, | ||
{ | ||
'source_uuid' => source_plates[1].uuid, | ||
'source_location' => 'A1', | ||
'destination_uuid' => destination_plates[0].uuid, | ||
'destination_location' => 'B1' | ||
}, | ||
{ | ||
'source_uuid' => source_plates[1].uuid, | ||
'source_location' => 'B1', | ||
'destination_uuid' => destination_plates[1].uuid, | ||
'destination_location' => 'B1' | ||
} | ||
] | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well caught