Skip to content

Commit

Permalink
Add data migration to fill owntracks points data
Browse files Browse the repository at this point in the history
  • Loading branch information
Freika committed Aug 15, 2024
1 parent 5c16cc6 commit 2b4a16d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
33 changes: 33 additions & 0 deletions db/data/20240815174852_add_owntracks_points_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

class AddOwntracksPointsData < ActiveRecord::Migration[7.1]
def up
Import.owntracks.each do |import|
import.points.each do |point|
params = OwnTracks::Params.new(point.raw_data).call

point.update!(
battery: params[:battery],
ping: params[:ping],
altitude: params[:altitude],
accuracy: params[:accuracy],
vertical_accuracy: params[:vertical_accuracy],
velocity: params[:velocity],
ssid: params[:ssid],
bssid: params[:bssid],
tracker_id: params[:tracker_id],
inrids: params[:inrids],
in_regions: params[:in_regions],
topic: params[:topic],
battery_status: params[:battery_status],
connection: params[:connection],
trigger: params[:trigger]
)
end
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
5 changes: 4 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b4a16d

Please sign in to comment.