Skip to content
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

Merged
merged 19 commits into from
May 17, 2022

Conversation

stevieing
Copy link
Collaborator

@stevieing stevieing commented Apr 26, 2022

Changes proposed in this pull request:

  • ...

@stevieing stevieing changed the title Removed graphql. Removed ONT routes. Removed ONT tasks. Removed some … DPL-274 - ONT - remove existing code Apr 26, 2022
@stevieing stevieing linked an issue Apr 26, 2022 that may be closed by this pull request
2 tasks
@JamesGlover JamesGlover force-pushed the dpl-274-ont-remove-existing-code branch from ac14091 to db9e226 Compare April 28, 2022 13:37
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.
@JamesGlover
Copy link
Contributor

Ahh bingo!

cerebris/jsonapi-resources#1308

It is applying the self.records filter from V1::Pacbio::TubeResource which is: ::Tube.by_pipeline(:pacbio) so we end up inadvertently filtering out out tubes.

Copy link
Contributor

@JamesGlover JamesGlover left a 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.

Comment on lines +158 to +171
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)
Copy link
Contributor

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,

Copy link
Contributor

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.

Comment on lines +44 to +48
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines -10 to -17

def self.includes_args(except = nil)
args = []
args << :material unless except == :material
args << :container unless except == :container

args
end
Copy link
Contributor

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.

@@ -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') }
Copy link
Contributor

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).

Copy link
Contributor

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.

Comment on lines 52 to 54
library.errors.each do |error|
errors.add(error.attribute, error.message)
end
Copy link
Contributor

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.

Comment on lines -1 to -21
# 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

Comment on lines 3 to 5
Array(klasses).each do |klass|
klass.define_method(:readonly?) { readonly }
end
Copy link
Contributor

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.

Comment on lines +18 to 20
def readonly?
true
end
Copy link
Contributor

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,.

@stevieing stevieing force-pushed the dpl-274-ont-remove-existing-code branch from 50524db to 3748f66 Compare May 5, 2022 11:35
@stevieing stevieing merged commit 47bf938 into develop May 17, 2022
@stevieing stevieing deleted the dpl-274-ont-remove-existing-code branch October 17, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants