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

Update sample_public_name for RVI Program - Bait Capture study #4586

Closed
wants to merge 39 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d2a1e63
Add TODO for removal of order_template.rb
sdjmchattie Dec 4, 2024
b99815b
Move the overridden method to the top of TagLayoutProcessor
sdjmchattie Dec 5, 2024
6abc012
Make OrderResource work
sdjmchattie Dec 5, 2024
dc4d9e2
Clean up code for creating the template attributes
sdjmchattie Dec 5, 2024
0e5e9c4
Add tests for orders
sdjmchattie Dec 9, 2024
a8b9d8b
Complete tests for OrderResource requests
sdjmchattie Dec 9, 2024
44fb065
Fix Rubocop issues
sdjmchattie Dec 9, 2024
bd34e04
Merge branch 'develop' into develop-Y24-190
sdjmchattie Dec 10, 2024
732b395
Merge branch 'develop-Y24-190' into Y24-190-support-limber-with-order…
sdjmchattie Dec 10, 2024
d26dfce
Fix rubocop complaint
sdjmchattie Dec 10, 2024
95a65bb
Clean up the OrdersProcessor and OrderResource
sdjmchattie Dec 16, 2024
70c8ee3
Fix Rubocop issues
sdjmchattie Dec 16, 2024
3d45f75
Merge branch 'develop' into develop-Y24-190
sdjmchattie Dec 16, 2024
b37bb16
Merge branch 'develop-Y24-190' into Y24-190-support-limber-with-order…
sdjmchattie Dec 16, 2024
1035686
Update sample_public_name for RVI Program - Bait Capture study
sabrine33 Jan 8, 2025
a989cd1
formatting
sabrine33 Jan 8, 2025
190186e
run rubocop
sabrine33 Jan 8, 2025
1ee65bb
Update rails to version 7.0.8.7
depfu[bot] Jan 8, 2025
e2a9a3c
Merge pull request #4551 from sanger/depfu/update/group/rails-7.0.8.7
yoldas Jan 8, 2025
7899d2f
Merge pull request #4543 from sanger/Y24-190-support-limber-with-orde…
sdjmchattie Jan 8, 2025
1e86205
Update factory_bot_rails to version 6.4.4
depfu[bot] Jan 8, 2025
7238682
Update Node.js to version 22.13.0
depfu[bot] Jan 9, 2025
350bf8d
Update postcss to version 8.4.49
depfu[bot] Jan 9, 2025
2875b4b
Update @rails/ujs to version 7.1.501
depfu[bot] Jan 9, 2025
eae764b
Merge pull request #4557 from sanger/depfu/update/yarn/@rails/ujs-7.1…
yoldas Jan 9, 2025
ad678b0
Merge pull request #4502 from sanger/depfu/update/yarn/postcss-8.4.49
yoldas Jan 9, 2025
8db61fe
Merge pull request #4588 from sanger/depfu/engine/yarn/nodejs-22.13.0
yoldas Jan 9, 2025
bcf93b1
Update Ruby to version 3.2.6
depfu[bot] Jan 9, 2025
5855031
Merge pull request #4479 from sanger/depfu/engine/ruby-3.2.6
yoldas Jan 9, 2025
edecf37
Update Ruby to version 3.3.6
depfu[bot] Jan 9, 2025
ee72d10
Merge pull request #4487 from sanger/depfu/engine/ruby-3.3.6
yoldas Jan 9, 2025
721fb23
Merge pull request #4525 from sanger/depfu/update/factory_bot_rails-6…
yoldas Jan 9, 2025
4262bc5
Update ruby-prof to version 1.7.1
depfu[bot] Jan 9, 2025
83a70ae
Merge pull request #4500 from sanger/depfu/update/ruby-prof-1.7.1
yoldas Jan 9, 2025
6f565df
Update sample_public_name for RVI Program - Bait Capture study
sabrine33 Jan 8, 2025
899fa6f
formatting
sabrine33 Jan 8, 2025
9549c99
run rubocop
sabrine33 Jan 8, 2025
4f2c7b7
Convert to a migration to use ORM functionalities and trigger MLHW ev…
sabrine33 Jan 13, 2025
6f91035
Merge remote-tracking branch 'origin/Y24-300-rake-task' into Y24-300-…
sabrine33 Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/tasks/update_sample_public_name_for_rvi_study.rake
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true
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')

Check warning on line 5 in lib/tasks/update_sample_public_name_for_rvi_study.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/update_sample_public_name_for_rvi_study.rake#L5

Added line #L5 was not covered by tests
Copy link
Contributor

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?

Copy link
Contributor Author

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.


ActiveRecord::Base.connection.execute(<<~SQLQUERY)

Check warning on line 7 in lib/tasks/update_sample_public_name_for_rvi_study.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/update_sample_public_name_for_rvi_study.rake#L7

Added line #L7 was not covered by tests
UPDATE sample_metadata
JOIN samples ON sample_metadata.sample_id = samples.id
JOIN study_samples ON sample_metadata.sample_id = study_samples.sample_id
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
Copy link
Contributor

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?


ActiveRecord::Base.connection.execute('COMMIT')
ActiveRecord::Base.connection.execute('SET autocommit = 1')

Check warning on line 17 in lib/tasks/update_sample_public_name_for_rvi_study.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/update_sample_public_name_for_rvi_study.rake#L16-L17

Added lines #L16 - L17 were not covered by tests

puts 'Sample public names updated successfully for RVI Program - Bait Capture study.'

Check warning on line 19 in lib/tasks/update_sample_public_name_for_rvi_study.rake

View check run for this annotation

Codecov / codecov/patch

lib/tasks/update_sample_public_name_for_rvi_study.rake#L19

Added line #L19 was not covered by tests
end
end
Loading