-
Notifications
You must be signed in to change notification settings - Fork 5
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
DPL-274 - ONT - remove existing code #745
Conversation
…other code that wasn't being used.
Temporarily rollback json-api-resources to fix: ./spec/requests/v1/pacbio/libraries_spec.rb:53 ./spec/requests/v1/pacbio/pools_spec.rb:96
ac14091
to
db9e226
Compare
The update to jsonapi-resources 0.10.6 broke the loading of tubes for pacbio library and pool resources. This appears to be related to the addition of the configuration option `use_related_resource_records_for_joins` cerebris/jsonapi-resources#1381 This is failing to function correctly in this case. By specifying the relationship explicitly, we disable this behaviour, and everything behaves as expected. I still haven't quite managed to get to the bottom of the problem. It may be we need to disable the behaviour globally.
Ahh bingo! cerebris/jsonapi-resources#1308 It is applying the self.records filter from |
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.
A few suggestions, and a couple of questions, but nothing critical.
rails (7.0.2.3) | ||
actioncable (= 7.0.2.3) | ||
actionmailbox (= 7.0.2.3) | ||
actionmailer (= 7.0.2.3) | ||
actionpack (= 7.0.2.3) | ||
actiontext (= 7.0.2.3) | ||
actionview (= 7.0.2.3) | ||
activejob (= 7.0.2.3) | ||
activemodel (= 7.0.2.3) | ||
activerecord (= 7.0.2.3) | ||
activestorage (= 7.0.2.3) | ||
activesupport (= 7.0.2.3) | ||
bundler (>= 1.15.0) | ||
railties (= 7.0.2.3) |
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.
I wonder if its worth considering only using a subset to these?
I don't think we need:
actioncable, actionmailer, actionmailbox, actiontext, activejob, activestorage.
I'm not even certain we need actionview, although it may be that Rails routes all its erb stuff through there,
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.
On the flip side, this is definitely simpler to maintain.
record.errors.add(error.attribute, error.message) | ||
elsif nested_attribute == :base | ||
record.errors.add(attribute, nested_error) | ||
else | ||
record.errors.add("#{attribute}.#{nested_attribute}", nested_error) |
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.
record.errors.add(error.attribute, error.message) | |
elsif nested_attribute == :base | |
record.errors.add(attribute, nested_error) | |
else | |
record.errors.add("#{attribute}.#{nested_attribute}", nested_error) | |
record.errors.add(error.attribute, error.message) | |
elsif nested_attribute == :base | |
record.errors.add(error.attribute, error.message) | |
else | |
record.errors.add("#{error.attribute}.#{nested_attribute}", error.message) |
Although this suggests we are either only using this with keys flattened, or aren't testing the cases where we @flatten_keys is false. We could consider simplifying this instead.
|
||
def self.includes_args(except = nil) | ||
args = [] | ||
args << :material unless except == :material | ||
args << :container unless except == :container | ||
|
||
args | ||
end |
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.
This bit of code had me itching every time I saw it.
app/models/ont/flowcell.rb
Outdated
@@ -12,14 +12,11 @@ class Flowcell < ApplicationRecord | |||
validates :position, | |||
presence: true, | |||
uniqueness: { scope: :ont_run_id, | |||
message: 'should only appear once within run' } | |||
message: I18n.t('errors.messages.uniqueness.flowcell') } |
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.
Ahh, mostly been flagging these Todo.
I hadn't considered being explicit here, and had intended to use the default rails message lookup:; which I've always found a bit obtuse, so being explicit is nice.
However might be nice to adjust this to match one of the default lookup routes, even if you are still explicit here. They are a touch verbose, although I also found this option, which lets you be concise, but still explicit (especially if its an easily grepable string).
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.
Oh, and as I said, obtuse, so sorry if this does already map to obe of the defaults.
app/models/pacbio/library_factory.rb
Outdated
library.errors.each do |error| | ||
errors.add(error.attribute, error.message) | ||
end |
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.
Can dry some of these out with the nested validation, but probably better to do when already touching this code.
# frozen_string_literal: true | ||
|
||
# www.mattsears.com/articles/2011/11/27ruby-blocks-as-dynamic-callbacks | ||
class Proc | ||
def callback(callable, *args) | ||
self === Class.new do | ||
method_name = callable.to_sym | ||
define_method(method_name) { |&block| block ? block.call(*args) : true } | ||
define_method("#{method_name}?") { true } | ||
def method_missing(*_args) | ||
super | ||
false | ||
end | ||
|
||
def respond_to_missing?(*) | ||
super | ||
true | ||
end | ||
end.new | ||
end | ||
end |
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.
I remember thinking this was a native feature I'd not seen before when I first came across it in the codebase.
@@ -0,0 +1,118 @@ | |||
# frozen_string_literal: true |
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.
Given you've already opted in to the 7.0 defaults, I think we can already lose this file.
db/schema.rb
Outdated
@@ -10,7 +10,7 @@ | |||
# | |||
# It's strongly recommended that you check this file into your version control system. | |||
|
|||
ActiveRecord::Schema.define(version: 2022_04_07_104659) do | |||
ActiveRecord::Schema[6.1].define(version: 2022_04_07_104659) do |
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.
Might be worth running rake db:schema:dump
now to update this to the Rails 7 version, otherwise there will be lots of changes next time someone touches the schema for real.
spec/support/read_only.rb
Outdated
Array(klasses).each do |klass| | ||
klass.define_method(:readonly?) { readonly } | ||
end |
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.
Might be better using mocks here as they'll get automatically torn down, removing the need for an after block, and reducing the risk of accidentally mutating the global state.
klasses.each do |klass|
allow_any_instance_of(Widget).to receive(:readonly?).and_return(readonly)
end
I think rubocop-rspec will complain, but I think its still a safer option.
def readonly? | ||
true | ||
end |
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.
I wonder if it would be safer to call readonly!
in an after_initialize call? That would have the advantage that we also set the @readonly
instance variable. Doesn't matter too much, as it should all be both temporary and precautionary,.
50524db
to
3748f66
Compare
Changes proposed in this pull request: