-
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
Update sample_public_name for RVI Program - Bait Capture study #4586
Conversation
Particularly when it comes to creating new Orders from a SubmissionTemplate
There are more to add, but this is WIP
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4586 +/- ##
===========================================
- Coverage 89.30% 89.21% -0.09%
===========================================
Files 1406 1407 +1
Lines 30010 30018 +8
===========================================
- Hits 26799 26780 -19
- Misses 3211 3238 +27 ☔ View full report in Codecov by Sentry. |
🚨 [security] [ruby] Update rails 7.0.8.1 → 7.0.8.7 (patch)
…r-templates Y24-190: Support Limber with Orders from SubmissionTemplates
….501 [js] Update @rails/ujs 7.1.3 → 7.1.501 (patch)
[js] Update postcss 8.4.39 → 8.4.49 (patch)
[js] Update Node.js 22.11.0 → 22.13.0
[ruby] Update Ruby 3.2.5 → 3.2.6
[ruby] Update Ruby 3.2.6 → 3.3.6
….4.4 [ruby] Update factory_bot_rails 6.4.3 → 6.4.4 (patch)
[ruby] Update ruby-prof 1.7.0 → 1.7.1 (patch)
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.
The SQL looks fine, but I've left a few questions about the approach.
namespace :samples do | ||
desc 'Update sample_public_name for RVI Program - Bait Capture study' | ||
task update_public_name: :environment do | ||
ActiveRecord::Base.connection.execute('SET autocommit = 0') |
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.
Could you explain the benefit of having autocommit turned off, please?
I was reading the docs - https://dev.mysql.com/doc/refman/8.4/en/innodb-autocommit-commit-rollback.html - and it looks like the benefit would come if there were multiple SQL statements - but we only have one here?
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.
You are right; it is only one SQL statement, but it runs on all the samples of the RVI studies (quite a lot). Turning off auto-commit ensures the atomicity of the operation.
JOIN studies ON study_samples.study_id = studies.id | ||
SET sample_metadata.sample_public_name = samples.sanger_sample_id | ||
WHERE studies.name = 'RVI Program - Bait Capture' AND sanger_sample_id LIKE 'RVI%'; | ||
SQLQUERY |
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.
Did you consider whether to check if sample_public_name
already has a value, to avoid overwriting it if it has been intentionally set already?
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.
Using SQL directly means not using the ORM... which I think might mean you're bypassing some useful functionality. When a sample (and hopefully sample metadata) is updated, Sequencescape automatically updates the corresponding value in the MLWH (via the RabbitMQ queue). If you directly use SQL, I don't think this will happen.
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.
Good point!
Oh and finally - What's your plan for testing? You could add some unit tests, or just test it in training (should definitely do this anyway). If just manual tests in training, you could put a couple of SQL queries here that you intend to run to check the data? Thanks! |
…ent updates if needed
Populate the sample_public_name field with sanger_sample_id values for samples associated with the 'RVI Program - Bait Capture' study, and where the sanger_sample_id starts with "RVI".