Move meta fields out of .meta for searchability
parent
b5921e6bd0
commit
be7a9a6470
|
@ -34,6 +34,13 @@ class Device < ApplicationRecord
|
|||
logs.all.last(max_log_count || DEFAULT_MAX_LOGS)
|
||||
end
|
||||
|
||||
def trim_log_list!
|
||||
logs
|
||||
.order(created_at: :desc)
|
||||
.offset(max_log_count || DEFAULT_MAX_LOGS)
|
||||
.destroy_all
|
||||
end
|
||||
|
||||
def self.current
|
||||
RequestStore.store[:device]
|
||||
end
|
||||
|
|
|
@ -25,6 +25,10 @@ class Log < ApplicationRecord
|
|||
self.meta[:type] ||= "info"
|
||||
end
|
||||
|
||||
def meta=(*)
|
||||
puts "This column is read-only now."
|
||||
end
|
||||
|
||||
def broadcast? # Logs get their own special channel. Don't echo twice!
|
||||
false
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class FlattenMetaColumn < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :logs, :type, :string, limit: 10
|
||||
add_column :logs, :major_version, :integer
|
||||
add_column :logs, :minor_version, :integer
|
||||
add_column :logs, :verbosity, :integer
|
||||
add_column :logs, :x, :integer
|
||||
add_column :logs, :y, :integer
|
||||
add_column :logs, :z, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
class MigrateAwayFromMetaColumn < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
# Grab all but the first 100 logs and destroy others so we don't migrate more
|
||||
# than we need to.
|
||||
# Migrate via log[name] = log.meta[name]
|
||||
Device.all.map { |d| d.trim_log_list! }
|
||||
Log.all.map do |log|
|
||||
log.meta.map do |(key,value)|
|
||||
log[key.to_sym] = log.meta[value]
|
||||
log.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20180328212540) do
|
||||
ActiveRecord::Schema.define(version: 20180330130914) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -240,6 +240,13 @@ ActiveRecord::Schema.define(version: 20180328212540) do
|
|||
t.integer "device_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "type", limit: 10
|
||||
t.integer "major_version"
|
||||
t.integer "minor_version"
|
||||
t.integer "verbosity"
|
||||
t.integer "x"
|
||||
t.integer "y"
|
||||
t.integer "z"
|
||||
t.index ["device_id"], name: "index_logs_on_device_id"
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export interface LabsFeature {
|
|||
/** Toggle label. */
|
||||
name: string;
|
||||
description: string;
|
||||
/** Entry for localStorage. Must be unique. */
|
||||
/** Configuration key name such as "disable_i18n". Must be unique. */
|
||||
storageKey: BooleanConfigKey;
|
||||
/** Placeholder value (use false). */
|
||||
value: boolean;
|
||||
|
|
|
@ -4,8 +4,8 @@ import { edit, save } from "../api/crud";
|
|||
import { getWebAppConfig } from "../resources/selectors_by_kind";
|
||||
|
||||
/**
|
||||
* HISTORICAL CONTEXT: We once stored user settings (like map zoom level) in localStorage and
|
||||
* would retrieve values via `Session.getBool("zoom_level")`
|
||||
* HISTORICAL CONTEXT: We once stored user settings (like map zoom level) in
|
||||
* localStorage and would retrieve values via `Session.getBool("zoom_level")`
|
||||
*
|
||||
* PROBLEM: localStorage is no longer used. Many parts of the app were accessing
|
||||
* values in places that did not have access to the Redux store.
|
||||
|
|
Loading…
Reference in New Issue