Commit fe8d739c by John Donnal

added fields to events

parent 1eb49f8a
...@@ -102,21 +102,6 @@ module Joule ...@@ -102,21 +102,6 @@ module Joule
stream = db_folder.event_streams.find_by_joule_id(stream_schema[:id]) stream = db_folder.event_streams.find_by_joule_id(stream_schema[:id])
stream ||= EventStream.new(db_folder: db_folder, db: db_folder.db) stream ||= EventStream.new(db_folder: db_folder, db: db_folder.db)
__update_event_stream(stream, stream_schema, db_folder.path) __update_event_stream(stream, stream_schema, db_folder.path)
size_on_disk+=stream.size_on_disk
unless stream.start_time.nil?
if start_time.nil?
start_time = stream.start_time
else
start_time = [stream.start_time, start_time].min
end
end
unless stream.end_time.nil?
if end_time.nil?
end_time = stream.end_time
else
end_time = [stream.end_time, end_time].max
end
end
updated_ids << stream_schema[:id] updated_ids << stream_schema[:id]
end end
# remove any streams that are no longer in the folder # remove any streams that are no longer in the folder
...@@ -161,12 +146,10 @@ module Joule ...@@ -161,12 +146,10 @@ module Joule
# add in extra attributes that require conversion # add in extra attributes that require conversion
attrs[:path] = "#{parent_path}/#{schema[:name]}" attrs[:path] = "#{parent_path}/#{schema[:name]}"
attrs[:joule_id] = schema[:id] attrs[:joule_id] = schema[:id]
attrs[:start_time] = schema[:data_info][:start_time] attrs[:start_time] = schema[:data_info][:start]
attrs[:end_time] = schema[:data_info][:end_time] attrs[:end_time] = schema[:data_info][:end]
attrs[:total_rows] = schema[:data_info][:rows] attrs[:event_count] = schema[:data_info][:event_count]
attrs[:total_time] = schema[:data_info][:total_time] attrs[:event_fields_json] = schema[:event_fields].to_json
attrs[:size_on_disk] = schema[:data_info][:bytes]
event_stream.update(attrs) event_stream.update(attrs)
end end
......
...@@ -11,8 +11,12 @@ class EventStream < ApplicationRecord ...@@ -11,8 +11,12 @@ class EventStream < ApplicationRecord
def self.defined_attributes def self.defined_attributes
[:name, :description] [:name, :description]
end end
def event_fields
return {} if event_fields_json.nil? or event_fields_json.empty?
JSON.parse(event_fields_json)
end
def self.json_keys def self.json_keys
[:id, :name, :description, :path, :start_time, [:id, :name, :description, :path, :start_time,
:end_time, :size_on_disk, :total_rows, :total_time] :end_time, :event_count, :event_fields]
end end
end end
\ No newline at end of file
class ModifyEventStream < ActiveRecord::Migration[6.0]
def change
remove_column :event_streams, :total_rows
remove_column :event_streams, :total_time
remove_column :event_streams, :size_on_disk
add_column :event_streams, :event_count, :integer
end
end
class AddFieldsToEventStream < ActiveRecord::Migration[6.0]
def change
add_column :event_streams, :event_fields, :string
end
end
class ChangeEventFieldsName < ActiveRecord::Migration[6.0]
def change
rename_column :event_streams, :event_fields, :event_fields_json
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_01_04_010931) do ActiveRecord::Schema.define(version: 2022_05_05_173955) do
create_table "data_apps", force: :cascade do |t| create_table "data_apps", force: :cascade do |t|
t.string "name" t.string "name"
...@@ -126,14 +126,13 @@ ActiveRecord::Schema.define(version: 2022_01_04_010931) do ...@@ -126,14 +126,13 @@ ActiveRecord::Schema.define(version: 2022_01_04_010931) do
t.string "path" t.string "path"
t.integer "start_time", limit: 8 t.integer "start_time", limit: 8
t.integer "end_time", limit: 8 t.integer "end_time", limit: 8
t.integer "total_rows", limit: 8
t.integer "total_time", limit: 8
t.integer "size_on_disk", limit: 8
t.integer "joule_id" t.integer "joule_id"
t.string "name" t.string "name"
t.string "description" t.string "description"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.integer "event_count"
t.string "event_fields_json"
t.index ["db_folder_id"], name: "index_event_streams_on_db_folder_id" t.index ["db_folder_id"], name: "index_event_streams_on_db_folder_id"
t.index ["db_id"], name: "index_event_streams_on_db_id" t.index ["db_id"], name: "index_event_streams_on_db_id"
t.index ["joule_id"], name: "index_event_streams_on_joule_id" t.index ["joule_id"], name: "index_event_streams_on_joule_id"
......
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