Code review comments.
Этот коммит содержится в:
@@ -1,5 +1,5 @@
|
|||||||
CREATE TABLE IF NOT EXISTS TrueUpReviewHistory (
|
CREATE TABLE IF NOT EXISTS TrueUpReviewHistory (
|
||||||
DueDate bigint(20),
|
DueDate bigint(20),
|
||||||
Completed boolean,
|
Completed boolean,
|
||||||
PRIMARY KEY (duedate)
|
PRIMARY KEY (DueDate)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ type TrueUpReviewPlugins struct {
|
|||||||
InactivePluginNames []string `json:"inactive_plugin_names"`
|
InactivePluginNames []string `json:"inactive_plugin_names"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TrueUpReviewPlugins) ToMap() map[string]any {
|
func (t *TrueUpReviewPlugins) ToMap() map[string]interface{} {
|
||||||
return map[string]any{
|
return map[string]interface{}{
|
||||||
"total_active_plugins": t.TotalActivePlugins,
|
"total_active_plugins": t.TotalActivePlugins,
|
||||||
"total_inactive_plugins": t.TotalInactivePlugins,
|
"total_inactive_plugins": t.TotalInactivePlugins,
|
||||||
"active_plugin_names": t.ActivePluginNames,
|
"active_plugin_names": t.ActivePluginNames,
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ type SqlStoreStores struct {
|
|||||||
notifyAdmin store.NotifyAdminStore
|
notifyAdmin store.NotifyAdminStore
|
||||||
postPriority store.PostPriorityStore
|
postPriority store.PostPriorityStore
|
||||||
postAcknowledgement store.PostAcknowledgementStore
|
postAcknowledgement store.PostAcknowledgementStore
|
||||||
trueUpReviewStatus store.TrueUpReviewStore
|
trueUpReview store.TrueUpReviewStore
|
||||||
}
|
}
|
||||||
|
|
||||||
type SqlStore struct {
|
type SqlStore struct {
|
||||||
@@ -221,7 +221,7 @@ func New(settings model.SqlSettings, metrics einterfaces.MetricsInterface) *SqlS
|
|||||||
store.stores.notifyAdmin = newSqlNotifyAdminStore(store)
|
store.stores.notifyAdmin = newSqlNotifyAdminStore(store)
|
||||||
store.stores.postPriority = newSqlPostPriorityStore(store)
|
store.stores.postPriority = newSqlPostPriorityStore(store)
|
||||||
store.stores.postAcknowledgement = newSqlPostAcknowledgementStore(store)
|
store.stores.postAcknowledgement = newSqlPostAcknowledgementStore(store)
|
||||||
store.stores.trueUpReviewStatus = newSqlTrueUpReviewStore(store)
|
store.stores.trueUpReview = newSqlTrueUpReviewStore(store)
|
||||||
|
|
||||||
store.stores.preference.(*SqlPreferenceStore).deleteUnusedFeatures()
|
store.stores.preference.(*SqlPreferenceStore).deleteUnusedFeatures()
|
||||||
|
|
||||||
@@ -978,7 +978,7 @@ func (ss *SqlStore) PostAcknowledgement() store.PostAcknowledgementStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ss *SqlStore) TrueUpReview() store.TrueUpReviewStore {
|
func (ss *SqlStore) TrueUpReview() store.TrueUpReviewStore {
|
||||||
return ss.stores.trueUpReviewStatus
|
return ss.stores.trueUpReview
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *SqlStore) DropAllTables() {
|
func (ss *SqlStore) DropAllTables() {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ hwIDAQAB
|
|||||||
|
|
||||||
var LicenseValidator LicenseValidatorIface
|
var LicenseValidator LicenseValidatorIface
|
||||||
|
|
||||||
const TrueUpReviewDueDay = 15
|
const trueUpReviewDueDay = 15
|
||||||
const BusinessQuaterStep = 3
|
const businessQuarterStep = 3
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if LicenseValidator == nil {
|
if LicenseValidator == nil {
|
||||||
@@ -232,16 +232,16 @@ func GetSanitizedClientLicense(l map[string]string) map[string]string {
|
|||||||
func GetNextTrueUpReviewDueDate(now time.Time) time.Time {
|
func GetNextTrueUpReviewDueDate(now time.Time) time.Time {
|
||||||
quaterEndMonths := []time.Month{time.March, time.June, time.September, time.December}
|
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 {
|
for _, month := range quaterEndMonths {
|
||||||
if now.Month() <= month && now.Day() <= TrueUpReviewDueDay {
|
if now.Month() <= month && now.Day() <= trueUpReviewDueDay {
|
||||||
nextQuaterEndMonth = month
|
nextQuarterEndMonth = month
|
||||||
break
|
break
|
||||||
} else if now.Month() <= month && now.Day() > TrueUpReviewDueDay {
|
} else if now.Month() <= month && now.Day() > trueUpReviewDueDay {
|
||||||
nextQuaterEndMonth = month + BusinessQuaterStep
|
nextQuarterEndMonth = month + businessQuarterStep
|
||||||
break
|
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())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) {
|
|||||||
assert.Equal(t, due.Day(), TrueUpReviewDueDay)
|
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)
|
now := time.Date(2022, time.March, 16, 0, 0, 0, 0, time.Local)
|
||||||
due := GetNextTrueUpReviewDueDate(now)
|
due := GetNextTrueUpReviewDueDate(now)
|
||||||
assert.Equal(t, time.June, due.Month())
|
assert.Equal(t, time.June, due.Month())
|
||||||
@@ -129,7 +129,7 @@ func TestGetNextTrueUpReviewDueDate(t *testing.T) {
|
|||||||
assert.Equal(t, time.March, due.Month())
|
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)
|
now := time.Date(2022, time.March, 15, 0, 0, 0, 0, time.Local)
|
||||||
due := GetNextTrueUpReviewDueDate(now)
|
due := GetNextTrueUpReviewDueDate(now)
|
||||||
assert.Equal(t, time.March, due.Month())
|
assert.Equal(t, time.March, due.Month())
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user