-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #4
base: main
Are you sure you want to change the base?
Development #4
Changes from 4 commits
02eebeb
bb66555
695553e
2d7d6b1
bd1470a
160bb85
61e8c5f
4970e75
be5db1d
33f500b
6df1943
b84f820
00c7d8e
a59a0c3
3696f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ez | ||
module Status | ||
class ApplicationRecord < ActiveRecord::Base | ||
self.abstract_class = true | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Ez | ||
module Status | ||
class Status < ApplicationRecord | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. class Record There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
self.table_name = Ez::Status.config.active_record_table_name | ||
|
||
validates :name, presence: true | ||
validates :result, presence: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove presence false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
validates :message, presence: false | ||
validates :value, presence: false | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
root to: 'status#index' | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,13 @@ module Status | |
configure do |config| | ||
config.status_base_controller = nil | ||
config.status_base_routes = nil | ||
|
||
config.layout = nil | ||
|
||
config.basic_auth_credentials = {} | ||
|
||
config.active_record_table_name = nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
config.monitors = [] | ||
|
||
config.ui_header = nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# rubocop:disable all | ||
module Ez | ||
module Status | ||
class MigrationsGenerator < Rails::Generators::Base | ||
def create_migration | ||
create_file "db/migrate/#{current_time}_create_#{table_name.to_s.underscore}.rb", | ||
"class Create#{table_name.to_s.classify} < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}] | ||
def change | ||
create_table :#{table_name.to_s.underscore} do |t| | ||
t.string :name, null: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. t.string :monitor_name, null: false There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
t.string :result, null: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. t.boolean :result, null: true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
t.string :message, null: true | ||
t.string :value, null: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. t.bigint :value, null: true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end | ||
" | ||
end | ||
|
||
private | ||
|
||
def config | ||
Ez::Status.config | ||
end | ||
|
||
def table_name | ||
raise 'You need setup active_record_table_name in config file' if config.active_record_table_name.blank? | ||
config.active_record_table_name | ||
end | ||
|
||
def current_time | ||
Time.now.strftime('%Y%m%d%H%M%S') | ||
end | ||
|
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://apidock.com/rails/v6.0.0/ActiveRecord/Persistence/ClassMethods/insert_all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done