Skip to content

Commit

Permalink
Fix: ensure that samples' measured signals are floats (#1981)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden authored Aug 1, 2023
1 parent 4c45652 commit 0220550
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions db/migrate/20230731140544_fix_samples_measured_signals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class FixSamplesMeasuredSignals < ActiveRecord::Migration[5.0]
def up
# make sure measured signals are always a float (the entity framework
# deletes the attribute from the core_fields when it's nil):
Sample
.where("core_fields LIKE '%measured_signal%'")
.preload(:sample_identifiers)
.find_each do |sample|
sample.measured_signal = sample.measured_signal.presence&.to_f
sample.save(validate: false)
end
end

def down
# nothing to do
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20221223203602) do
ActiveRecord::Schema.define(version: 20230731140544) do

create_table "alert_condition_results", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci" do |t|
t.string "result"
Expand Down

0 comments on commit 0220550

Please sign in to comment.