From 66e312b72fb06be545929a339d6ed3a239fc6c34 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Thu, 2 Sep 2021 22:44:00 -0400 Subject: [PATCH] Remove old memory uptime implementation and auto migration --- core/uptime.go | 10 ---------- storage/store/memory/uptime.go | 26 -------------------------- 2 files changed, 36 deletions(-) diff --git a/core/uptime.go b/core/uptime.go index 121aded7..514b4a77 100644 --- a/core/uptime.go +++ b/core/uptime.go @@ -3,16 +3,6 @@ package core // Uptime is the struct that contains the relevant data for calculating the uptime as well as the uptime itself // and some other statistics type Uptime struct { - // SuccessfulExecutionsPerHour is a map containing the number of successes (value) - // for every hourly unix timestamps (key) - // Deprecated - SuccessfulExecutionsPerHour map[int64]uint64 `json:"-"` - - // TotalExecutionsPerHour is a map containing the total number of checks (value) - // for every hourly unix timestamps (key) - // Deprecated - TotalExecutionsPerHour map[int64]uint64 `json:"-"` - // HourlyStatistics is a map containing metrics collected (value) for every hourly unix timestamps (key) // // Used only if the storage type is memory diff --git a/storage/store/memory/uptime.go b/storage/store/memory/uptime.go index 7d591c70..d75a309a 100644 --- a/storage/store/memory/uptime.go +++ b/storage/store/memory/uptime.go @@ -1,7 +1,6 @@ package memory import ( - "log" "time" "github.com/TwinProduction/gatus/core" @@ -15,10 +14,6 @@ const ( // processUptimeAfterResult processes the result by extracting the relevant from the result and recalculating the uptime // if necessary func processUptimeAfterResult(uptime *core.Uptime, result *core.Result) { - // XXX: Remove this on v3.0.0 - if len(uptime.SuccessfulExecutionsPerHour) != 0 || len(uptime.TotalExecutionsPerHour) != 0 { - migrateUptimeToHourlyStatistics(uptime) - } if uptime.HourlyStatistics == nil { uptime.HourlyStatistics = make(map[int64]*core.HourlyUptimeStatistics) } @@ -46,24 +41,3 @@ func processUptimeAfterResult(uptime *core.Uptime, result *core.Result) { } } } - -// XXX: Remove this on v3.0.0 -// Deprecated -func migrateUptimeToHourlyStatistics(uptime *core.Uptime) { - log.Println("[migrateUptimeToHourlyStatistics] Got", len(uptime.SuccessfulExecutionsPerHour), "entries for successful executions and", len(uptime.TotalExecutionsPerHour), "entries for total executions") - uptime.HourlyStatistics = make(map[int64]*core.HourlyUptimeStatistics) - for hourlyUnixTimestamp, totalExecutions := range uptime.TotalExecutionsPerHour { - if totalExecutions == 0 { - log.Println("[migrateUptimeToHourlyStatistics] Skipping entry at", hourlyUnixTimestamp, "because total number of executions is 0") - continue - } - uptime.HourlyStatistics[hourlyUnixTimestamp] = &core.HourlyUptimeStatistics{ - TotalExecutions: totalExecutions, - SuccessfulExecutions: uptime.SuccessfulExecutionsPerHour[hourlyUnixTimestamp], - TotalExecutionsResponseTime: 0, - } - } - log.Println("[migrateUptimeToHourlyStatistics] Migrated", len(uptime.HourlyStatistics), "entries") - uptime.SuccessfulExecutionsPerHour = nil - uptime.TotalExecutionsPerHour = nil -}