From b6bd3a789667620ebd39937c16c327f5f1891bee Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 21 Oct 2019 16:02:39 +0200 Subject: [PATCH] Replace duration with flexible_duration --- configobject/history/history.go | 4 ++-- configobject/nullrows/nullrows.go | 2 +- configobject/objecttypes/downtime/downtime.go | 6 +++--- etc/schema/mysql/downtime.sql | 4 ++-- etc/schema/mysql/host.sql | 4 ++-- etc/schema/mysql/service.sql | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configobject/history/history.go b/configobject/history/history.go index 841f6b9c..3a82acf0 100644 --- a/configobject/history/history.go +++ b/configobject/history/history.go @@ -168,7 +168,7 @@ func stateHistoryWorker(super *supervisor.Supervisor, objectType string) { func downtimeHistoryWorker(super *supervisor.Supervisor, objectType string) { statements := []string{ `REPLACE INTO ` + objectType + `_downtime_history (downtime_id, environment_id, ` + objectType + `_id, triggered_by_id, entry_time,` + - `author, comment, is_flexible, duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time)` + + `author, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time)` + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, `REPLACE INTO `+objectType+`_history (id, environment_id, `+objectType+`_id, notification_history_id,` + `state_history_id, downtime_history_id, comment_history_id, flapping_history_id, event_type, event_time)` + @@ -191,7 +191,7 @@ func downtimeHistoryWorker(super *supervisor.Supervisor, objectType string) { values["author"], values["comment"], utils.RedisIntToDBBoolean(values["is_flexible"]), - values["duration"], + values["flexible_duration"], values["scheduled_start_time"], values["scheduled_end_time"], utils.RedisIntToDBBoolean(values["was_started"]), diff --git a/configobject/nullrows/nullrows.go b/configobject/nullrows/nullrows.go index 45fe8e5e..fc16d405 100644 --- a/configobject/nullrows/nullrows.go +++ b/configobject/nullrows/nullrows.go @@ -52,7 +52,7 @@ func InsertNullRows(super *supervisor.Supervisor) { // *_downtime_history execFunc( objectType + "_downtime_history", - fmt.Sprintf("REPLACE INTO %s_downtime_history(downtime_id, environment_id, %s_id, triggered_by_id, entry_time, author, comment, is_flexible, duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", objectType, objectType), + fmt.Sprintf("REPLACE INTO %s_downtime_history(downtime_id, environment_id, %s_id, triggered_by_id, entry_time, author, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", objectType, objectType), emptyID, super.EnvId, emptyID, emptyID, 0, "", "", "y", 0, 0, 0, "y", 0, 0, "y", "y", 0, 0, ) diff --git a/configobject/objecttypes/downtime/downtime.go b/configobject/objecttypes/downtime/downtime.go index 15a7ac91..6e40a22b 100644 --- a/configobject/objecttypes/downtime/downtime.go +++ b/configobject/objecttypes/downtime/downtime.go @@ -22,7 +22,7 @@ var ( "entry_time", "scheduled_start_time", "scheduled_end_time", - "duration", + "flexible_duration", "is_flexible", "is_in_effect", "actual_start_time", @@ -45,7 +45,7 @@ type Downtime struct { EntryTime float64 `json:"entry_time"` ScheduledStartTime float64 `json:"scheduled_start_time"` ScheduledEndTime float64 `json:"scheduled_end_time"` - Duration float64 `json:"duration"` + FlexibleDuration float64 `json:"flexible_duration"` IsFlexible bool `json:"is_flexible"` IsInEffect bool `json:"is_in_effect"` ActualStartTime float64 `json:"actual_start_time"` @@ -82,7 +82,7 @@ func (d *Downtime) UpdateValues() []interface{} { d.EntryTime, d.ScheduledStartTime, d.ScheduledEndTime, - d.Duration, + d.FlexibleDuration, utils.Bool[d.IsFlexible], utils.Bool[d.IsInEffect], d.ActualStartTime, diff --git a/etc/schema/mysql/downtime.sql b/etc/schema/mysql/downtime.sql index 23531ee6..5e49a346 100644 --- a/etc/schema/mysql/downtime.sql +++ b/etc/schema/mysql/downtime.sql @@ -18,12 +18,12 @@ CREATE TABLE downtime ( entry_time bigint(20) unsigned NOT NULL, scheduled_start_time bigint(20) unsigned NOT NULL, scheduled_end_time bigint(20) unsigned NOT NULL, - duration bigint(20) unsigned NOT NULL, + flexible_duration bigint(20) unsigned NOT NULL, is_flexible enum('y', 'n') NOT NULL, is_in_effect enum('y', 'n') NOT NULL, actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the host went into a problem state during the downtimes timeframe', - actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise', + actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise', zone_id binary(20) DEFAULT NULL COMMENT 'zone.id', diff --git a/etc/schema/mysql/host.sql b/etc/schema/mysql/host.sql index 98631ea6..7c340c12 100644 --- a/etc/schema/mysql/host.sql +++ b/etc/schema/mysql/host.sql @@ -191,12 +191,12 @@ CREATE TABLE host_downtime_history ( author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci, comment text NOT NULL, is_flexible enum('y', 'n') NOT NULL, - duration bigint(20) unsigned NOT NULL, + flexible_duration bigint(20) unsigned NOT NULL, scheduled_start_time bigint(20) unsigned NOT NULL, scheduled_end_time bigint(20) unsigned NOT NULL, was_started enum('y', 'n') NOT NULL, actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the host went into a problem state during the downtimes timeframe', - actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise', + actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise', was_cancelled enum('y', 'n') NOT NULL, is_in_effect enum('y', 'n') NOT NULL, trigger_time bigint(20) unsigned NOT NULL, diff --git a/etc/schema/mysql/service.sql b/etc/schema/mysql/service.sql index f7d304a5..8da0592b 100644 --- a/etc/schema/mysql/service.sql +++ b/etc/schema/mysql/service.sql @@ -184,12 +184,12 @@ CREATE TABLE service_downtime_history ( author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci, comment text NOT NULL, is_flexible enum('y', 'n') NOT NULL, - duration bigint(20) unsigned NOT NULL, + flexible_duration bigint(20) unsigned NOT NULL, scheduled_start_time bigint(20) unsigned NOT NULL, scheduled_end_time bigint(20) unsigned NOT NULL, was_started enum('y', 'n') NOT NULL, actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the service went into a problem state during the downtimes timeframe', - actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise', + actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise', was_cancelled enum('y', 'n') NOT NULL, is_in_effect enum('y', 'n') NOT NULL, trigger_time bigint(20) unsigned NOT NULL,