From c633a1d2fa80fef4743638e203c5e4eda8944b46 Mon Sep 17 00:00:00 2001 From: Conor Macpherson Date: Tue, 27 Dec 2022 16:03:04 -0500 Subject: [PATCH] Code review comments. --- .../000101_create_true_up_review_history.up.sql | 2 +- model/true_up_review_profile.go | 4 ++-- store/sqlstore/store.go | 6 +++--- utils/license.go | 16 ++++++++-------- utils/license_test.go | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/db/migrations/mysql/000101_create_true_up_review_history.up.sql b/db/migrations/mysql/000101_create_true_up_review_history.up.sql index 5ed4eeb6ec..5b25ffdb80 100644 --- a/db/migrations/mysql/000101_create_true_up_review_history.up.sql +++ b/db/migrations/mysql/000101_create_true_up_review_history.up.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS TrueUpReviewHistory ( DueDate bigint(20), Completed boolean, - PRIMARY KEY (duedate) + PRIMARY KEY (DueDate) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/model/true_up_review_profile.go b/model/true_up_review_profile.go index 7ef3bed75a..d396488ae4 100644 --- a/model/true_up_review_profile.go +++ b/model/true_up_review_profile.go @@ -25,8 +25,8 @@ type TrueUpReviewPlugins struct { InactivePluginNames []string `json:"inactive_plugin_names"` } -func (t *TrueUpReviewPlugins) ToMap() map[string]any { - return map[string]any{ +func (t *TrueUpReviewPlugins) ToMap() map[string]interface{} { + return map[string]interface{}{ "total_active_plugins": t.TotalActivePlugins, "total_inactive_plugins": t.TotalInactivePlugins, "active_plugin_names": t.ActivePluginNames, diff --git a/store/sqlstore/store.go b/store/sqlstore/store.go index 9a1ceceb2d..0337a0d735 100644 --- a/store/sqlstore/store.go +++ b/store/sqlstore/store.go @@ -112,7 +112,7 @@ type SqlStoreStores struct { notifyAdmin store.NotifyAdminStore postPriority store.PostPriorityStore postAcknowledgement store.PostAcknowledgementStore - trueUpReviewStatus store.TrueUpReviewStore + trueUpReview store.TrueUpReviewStore } type SqlStore struct { @@ -221,7 +221,7 @@ func New(settings model.SqlSettings, metrics einterfaces.MetricsInterface) *SqlS store.stores.notifyAdmin = newSqlNotifyAdminStore(store) store.stores.postPriority = newSqlPostPriorityStore(store) store.stores.postAcknowledgement = newSqlPostAcknowledgementStore(store) - store.stores.trueUpReviewStatus = newSqlTrueUpReviewStore(store) + store.stores.trueUpReview = newSqlTrueUpReviewStore(store) store.stores.preference.(*SqlPreferenceStore).deleteUnusedFeatures() @@ -978,7 +978,7 @@ func (ss *SqlStore) PostAcknowledgement() store.PostAcknowledgementStore { } func (ss *SqlStore) TrueUpReview() store.TrueUpReviewStore { - return ss.stores.trueUpReviewStatus + return ss.stores.trueUpReview } func (ss *SqlStore) DropAllTables() { diff --git a/utils/license.go b/utils/license.go index 69435f7a43..cca1978558 100644 --- a/utils/license.go +++ b/utils/license.go @@ -35,8 +35,8 @@ hwIDAQAB var LicenseValidator LicenseValidatorIface -const TrueUpReviewDueDay = 15 -const BusinessQuaterStep = 3 +const trueUpReviewDueDay = 15 +const businessQuarterStep = 3 func init() { if LicenseValidator == nil { @@ -232,16 +232,16 @@ func GetSanitizedClientLicense(l map[string]string) map[string]string { func GetNextTrueUpReviewDueDate(now time.Time) time.Time { quaterEndMonths := []time.Month{time.March, time.June, time.September, time.December} - var nextQuaterEndMonth time.Month = time.March + var nextQuarterEndMonth time.Month = time.March for _, month := range quaterEndMonths { - if now.Month() <= month && now.Day() <= TrueUpReviewDueDay { - nextQuaterEndMonth = month + if now.Month() <= month && now.Day() <= trueUpReviewDueDay { + nextQuarterEndMonth = month break - } else if now.Month() <= month && now.Day() > TrueUpReviewDueDay { - nextQuaterEndMonth = month + BusinessQuaterStep + } else if now.Month() <= month && now.Day() > trueUpReviewDueDay { + nextQuarterEndMonth = month + businessQuarterStep break } } - return time.Date(now.Year(), nextQuaterEndMonth, TrueUpReviewDueDay, 0, 0, 0, 0, now.Location()) + return time.Date(now.Year(), nextQuarterEndMonth, trueUpReviewDueDay, 0, 0, 0, 0, now.Location()) } diff --git a/utils/license_test.go b/utils/license_test.go index 541fda3227..159ebcdedd 100644 --- a/utils/license_test.go +++ b/utils/license_test.go @@ -111,7 +111,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) { assert.Equal(t, due.Day(), TrueUpReviewDueDay) }) - t.Run("Due date will always be in next quater if the current date is past the 15th", func(t *testing.T) { + t.Run("Due date will always be in next quarter if the current date is past the 15th", func(t *testing.T) { now := time.Date(2022, time.March, 16, 0, 0, 0, 0, time.Local) due := GetNextTrueUpReviewDueDate(now) assert.Equal(t, time.June, due.Month()) @@ -129,7 +129,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) { assert.Equal(t, time.March, due.Month()) }) - t.Run("Due date will always be in the current quater if the current date is before or on the 15th", func(t *testing.T) { + t.Run("Due date will always be in the current quarter if the current date is before or on the 15th", func(t *testing.T) { now := time.Date(2022, time.March, 15, 0, 0, 0, 0, time.Local) due := GetNextTrueUpReviewDueDate(now) assert.Equal(t, time.March, due.Month())