Commit 66fc4c14 by John Donnal

added active attribute to data streams

parent 62b52f37
......@@ -27,6 +27,13 @@ module Joule
# go through the schema and update the database
@db.root_folder ||= DbFolder.create(db: @db)
__update_folder(@db.root_folder, schema, '')
if not schema[:active_data_streams].nil?
active_stream_ids = schema[:active_data_streams]
# activate currently inactive streams
DbStream.where(db_id: @db.id, active: false, joule_id: active_stream_ids).update(active: true)
# deactivate streams that are no longer active
DbStream.where(db_id: @db.id, active: true).where.not(joule_id: active_stream_ids).update(active: false)
end
DbStream.destroy(@deleted_db_streams)
EventStream.destroy(@deleted_event_streams)
DbFolder.destroy(@deleted_folders)
......
......@@ -28,7 +28,7 @@ class DbStream < ApplicationRecord
validates_with DbDataTypeValidator
def self.defined_attributes
[:name, :name_abbrev, :description, :hidden, :data_type, :locked]
[:name, :name_abbrev, :description, :hidden, :data_type, :locked, :active]
end
def data_format
......@@ -47,7 +47,7 @@ class DbStream < ApplicationRecord
end
def self.json_keys
[:id, :name, :description, :path, :start_time,
[:id, :name, :description, :path, :start_time, :active,
:end_time, :size_on_disk, :total_rows, :total_time,
:data_type, :name_abbrev, :delete_locked, :locked, :hidden]
end
......
class AddActiveFieldToDbStream < ActiveRecord::Migration[7.0]
def change
add_column :db_streams, :active, :boolean, default: false
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_06_23_142722) do
ActiveRecord::Schema[7.0].define(version: 2023_08_16_022450) do
create_table "data_apps", force: :cascade do |t|
t.string "name"
t.string "joule_id"
......@@ -103,6 +103,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_06_23_142722) do
t.integer "joule_id"
t.boolean "locked"
t.datetime "last_update", default: "1970-01-01 00:00:00"
t.boolean "active", default: false
t.index ["joule_id"], name: "index_db_streams_on_joule_id"
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment