-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect uptime data in daily heartbeat from connect-ng
- Loading branch information
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class SystemUptime < ApplicationRecord | ||
belongs_to :system | ||
|
||
validates :system_id, presence: true | ||
validates :online_at_day, presence: true | ||
validates :online_at_hours, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CreateSystemUptimes < ActiveRecord::Migration[6.1] | ||
def change | ||
safety_assured do | ||
create_table :system_uptimes, id: false do |t| | ||
t.bigint :system_id, null: false | ||
t.date :online_at_day, null: false | ||
t.column :online_at_hours, 'binary(24)', null: false | ||
t.timestamps | ||
end | ||
|
||
commit_db_transaction | ||
|
||
add_index :system_uptimes, %i[system_id online_at_day online_at_hours], unique: true, name: 'id_online_day_hours' | ||
|
||
add_foreign_key :system_uptimes, :systems, column: :system_id, validate: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SystemUptime, type: :model do | ||
it { is_expected.to validate_presence_of(:system_id) } | ||
it { is_expected.to validate_presence_of(:online_at_day) } | ||
it { is_expected.to validate_presence_of(:online_at_hours) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters