Deprecate admin advisor (#26045)
* Deprecate admin advisor * Webapp portion * More webapp deprecation * More cleanup * Linting * emoved metric ack dialog from annoucenemet bar * Cleanued up uninsed i18n strings * Updated test * fixed types * Updating server test * Updated i18n * Updated cypress test: * Updated cypress test: --------- Co-authored-by: harshil Sharma <harshilsharma63@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dc8fc773dc
Коммит
e9b9d4ff60
@@ -9448,24 +9448,6 @@ func (s *OpenTracingLayerSystemStore) SaveOrUpdate(system *model.System) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "SystemStore.SaveOrUpdateWithWarnMetricHandling")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
s.Root.Store.SetContext(origCtx)
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system)
|
||||
if err != nil {
|
||||
span.LogFields(spanlog.Error(err))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerSystemStore) Update(system *model.System) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "SystemStore.Update")
|
||||
|
||||
@@ -10799,27 +10799,6 @@ func (s *RetryLayerSystemStore) SaveOrUpdate(system *model.System) error {
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerSystemStore) Update(system *model.System) error {
|
||||
|
||||
tries := 0
|
||||
|
||||
@@ -6,16 +6,12 @@ package sqlstore
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
sq "github.com/mattermost/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||
)
|
||||
|
||||
type SqlSystemStore struct {
|
||||
@@ -59,24 +55,6 @@ func (s SqlSystemStore) SaveOrUpdate(system *model.System) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
||||
if err := s.SaveOrUpdate(system); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if strings.HasPrefix(system.Name, model.WarnMetricStatusStorePrefix) &&
|
||||
(system.Value == model.WarnMetricStatusRunonce || system.Value == model.WarnMetricStatusLimitReached) {
|
||||
if err := s.SaveOrUpdate(&model.System{
|
||||
Name: model.SystemWarnMetricLastRunTimestampKey,
|
||||
Value: strconv.FormatInt(utils.MillisFromTime(time.Now()), 10),
|
||||
}); err != nil {
|
||||
return errors.Wrapf(err, "failed to save system property with name=%s", model.SystemWarnMetricLastRunTimestampKey)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlSystemStore) Update(system *model.System) error {
|
||||
query := "UPDATE Systems SET Value=:Value WHERE Name=:Name"
|
||||
if _, err := s.GetMasterX().NamedExec(query, system); err != nil {
|
||||
|
||||
@@ -586,7 +586,6 @@ type SystemStore interface {
|
||||
GetByName(name string) (*model.System, error)
|
||||
PermanentDeleteByName(name string) (*model.System, error)
|
||||
InsertIfExists(system *model.System) (*model.System, error)
|
||||
SaveOrUpdateWithWarnMetricHandling(system *model.System) error
|
||||
}
|
||||
|
||||
type WebhookStore interface {
|
||||
|
||||
@@ -146,20 +146,6 @@ func (_m *SystemStore) SaveOrUpdate(system *model.System) error {
|
||||
return r0
|
||||
}
|
||||
|
||||
// SaveOrUpdateWithWarnMetricHandling provides a mock function with given fields: system
|
||||
func (_m *SystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
||||
ret := _m.Called(system)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(*model.System) error); ok {
|
||||
r0 = rf(system)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Update provides a mock function with given fields: system
|
||||
func (_m *SystemStore) Update(system *model.System) error {
|
||||
ret := _m.Called(system)
|
||||
|
||||
@@ -22,7 +22,6 @@ func TestSystemStore(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
t.Run("InsertIfExists", func(t *testing.T) {
|
||||
testInsertIfExists(t, rctx, ss)
|
||||
})
|
||||
t.Run("SaveOrUpdateWithWarnMetricHandling", func(t *testing.T) { testSystemStoreSaveOrUpdateWithWarnMetricHandling(t, rctx, ss) })
|
||||
t.Run("GetByNameNoEntries", func(t *testing.T) { testSystemStoreGetByNameNoEntries(t, rctx, ss) })
|
||||
}
|
||||
|
||||
@@ -73,33 +72,6 @@ func testSystemStoreSaveOrUpdate(t *testing.T, rctx request.CTX, ss store.Store)
|
||||
assert.Equal(t, system.Value, res.Value)
|
||||
}
|
||||
|
||||
func testSystemStoreSaveOrUpdateWithWarnMetricHandling(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
system := &model.System{Name: model.NewId(), Value: "value"}
|
||||
|
||||
err := ss.System().SaveOrUpdateWithWarnMetricHandling(system)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.System().GetByName(model.SystemWarnMetricLastRunTimestampKey)
|
||||
assert.Error(t, err)
|
||||
|
||||
system.Name = "warn_metric_number_of_active_users_100"
|
||||
system.Value = model.WarnMetricStatusRunonce
|
||||
err = ss.System().SaveOrUpdateWithWarnMetricHandling(system)
|
||||
require.NoError(t, err)
|
||||
|
||||
val1, nerr := ss.System().GetByName(model.SystemWarnMetricLastRunTimestampKey)
|
||||
assert.NoError(t, nerr)
|
||||
|
||||
system.Name = "warn_metric_number_of_active_users_100"
|
||||
system.Value = model.WarnMetricStatusAck
|
||||
err = ss.System().SaveOrUpdateWithWarnMetricHandling(system)
|
||||
require.NoError(t, err)
|
||||
|
||||
val2, nerr := ss.System().GetByName(model.SystemWarnMetricLastRunTimestampKey)
|
||||
assert.NoError(t, nerr)
|
||||
assert.Equal(t, val1, val2)
|
||||
}
|
||||
|
||||
func testSystemStoreGetByNameNoEntries(t *testing.T, rctx request.CTX, ss store.Store) {
|
||||
res, nErr := ss.System().GetByName(model.SystemFirstAdminVisitMarketplace)
|
||||
_, ok := nErr.(*store.ErrNotFound)
|
||||
|
||||
@@ -8505,22 +8505,6 @@ func (s *TimerLayerSystemStore) SaveOrUpdate(system *model.System) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerSystemStore) SaveOrUpdateWithWarnMetricHandling(system *model.System) error {
|
||||
start := time.Now()
|
||||
|
||||
err := s.SystemStore.SaveOrUpdateWithWarnMetricHandling(system)
|
||||
|
||||
elapsed := float64(time.Since(start)) / float64(time.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
success := "false"
|
||||
if err == nil {
|
||||
success = "true"
|
||||
}
|
||||
s.Root.Metrics.ObserveStoreMethodDuration("SystemStore.SaveOrUpdateWithWarnMetricHandling", success, elapsed)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerSystemStore) Update(system *model.System) error {
|
||||
start := time.Now()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user