mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Add data migration to fill owntracks points data
This commit is contained in:
parent
5c16cc6dca
commit
2b4a16d6cb
2 changed files with 37 additions and 1 deletions
33
db/data/20240815174852_add_owntracks_points_data.rb
Normal file
33
db/data/20240815174852_add_owntracks_points_data.rb
Normal file
|
|
@ -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
db/schema.rb
generated
5
db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_07_21_183116) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_08_08_121027) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -53,6 +53,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_21_183116) do
|
|||
t.index ["user_id"], name: "index_areas_on_user_id"
|
||||
end
|
||||
|
||||
create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t|
|
||||
end
|
||||
|
||||
create_table "exports", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "url"
|
||||
|
|
|
|||
Loading…
Reference in a new issue