StatusStore migration (#14978)
* Finished! * Typos * Fix error * Fix layers * Lint: remove unnecessary use of sprint * Fix shadowing err
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
909cda6d49
Коммит
32b7d2b5f1
@@ -637,7 +637,7 @@ func TestCreatePostCheckOnlineStatus(t *testing.T) {
|
||||
|
||||
_, err = th.App.GetStatus(th.BasicUser.Id)
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, "store.sql_status.get.missing.app_error", err.Id)
|
||||
assert.Equal(t, "app.status.get.missing.app_error", err.Id)
|
||||
|
||||
req = httptest.NewRequest("POST", "/api/v4/posts", strings.NewReader(post.ToJson()))
|
||||
req.Header.Set(model.HEADER_AUTH, "Bearer "+session.Token)
|
||||
|
||||
@@ -467,7 +467,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
if s.Audit == nil {
|
||||
s.Audit = &audit.Audit{}
|
||||
s.Audit.Init(audit.DefMaxQueueSize)
|
||||
if err := s.configureAudit(s.Audit, allowAdvancedLogging); err != nil {
|
||||
if err = s.configureAudit(s.Audit, allowAdvancedLogging); err != nil {
|
||||
mlog.Error("Error configuring audit", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
@@ -488,8 +488,8 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true })
|
||||
}
|
||||
|
||||
if appErr = s.Store.Status().ResetAll(); appErr != nil {
|
||||
mlog.Error("Error to reset the server status.", mlog.Err(appErr))
|
||||
if err = s.Store.Status().ResetAll(); err != nil {
|
||||
mlog.Error("Error to reset the server status.", mlog.Err(err))
|
||||
}
|
||||
|
||||
if s.startMetrics && s.Metrics != nil {
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
func (a *App) AddStatusCacheSkipClusterSend(status *model.Status) {
|
||||
@@ -69,7 +73,7 @@ func (a *App) GetStatusesByIds(userIds []string) (map[string]interface{}, *model
|
||||
if len(missingUserIds) > 0 {
|
||||
statuses, err := a.Srv().Store.Status().GetByIds(missingUserIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetStatusesByIds", "app.status.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, s := range statuses {
|
||||
@@ -117,7 +121,7 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap
|
||||
if len(missingUserIds) > 0 {
|
||||
statuses, err := a.Srv().Store.Status().GetByIds(missingUserIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, model.NewAppError("GetUserStatusesByIds", "app.status.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, s := range statuses {
|
||||
@@ -342,7 +346,18 @@ func (a *App) GetStatus(userId string) (*model.Status, *model.AppError) {
|
||||
return status, nil
|
||||
}
|
||||
|
||||
return a.Srv().Store.Status().Get(userId)
|
||||
status, err := a.Srv().Store.Status().Get(userId)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
case errors.As(err, &nfErr):
|
||||
return nil, model.NewAppError("GetStatus", "app.status.get.missing.app_error", nil, nfErr.Error(), http.StatusNotFound)
|
||||
default:
|
||||
return nil, model.NewAppError("GetStatus", "app.status.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func (a *App) IsUserAway(lastActivityAt int64) bool {
|
||||
|
||||
36
i18n/en.json
36
i18n/en.json
@@ -4458,6 +4458,14 @@
|
||||
"id": "app.session.update_device_id.app_error",
|
||||
"translation": "Unable to update the device id."
|
||||
},
|
||||
{
|
||||
"id": "app.status.get.app_error",
|
||||
"translation": "Encountered an error retrieving the status."
|
||||
},
|
||||
{
|
||||
"id": "app.status.get.missing.app_error",
|
||||
"translation": "No entry for that status exists."
|
||||
},
|
||||
{
|
||||
"id": "app.submit_interactive_dialog.json_error",
|
||||
"translation": "Encountered an error encoding JSON for the interactive dialog."
|
||||
@@ -7302,34 +7310,6 @@
|
||||
"id": "store.sql_post.search.disabled",
|
||||
"translation": "Searching has been disabled on this server. Please contact your System Administrator."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.get.app_error",
|
||||
"translation": "Encountered an error retrieving the status."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.get.missing.app_error",
|
||||
"translation": "No entry for that status exists."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.get_total_active_users_count.app_error",
|
||||
"translation": "We could not count the active users."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.reset_all.app_error",
|
||||
"translation": "Encountered an error resetting all the statuses."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.save.app_error",
|
||||
"translation": "Encountered an error saving the status."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.update.app_error",
|
||||
"translation": "Encountered an error updating the status."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_status.update_last_activity_at.app_error",
|
||||
"translation": "Unable to update the last activity date and time of the user."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_system.get.app_error",
|
||||
"translation": "We encountered an error finding the system properties."
|
||||
|
||||
@@ -6224,7 +6224,7 @@ func (s *OpenTracingLayerSessionStore) UpdateRoles(userId string, roles string)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
func (s *OpenTracingLayerStatusStore) Get(userId string) (*model.Status, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.Get")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -6242,7 +6242,7 @@ func (s *OpenTracingLayerStatusStore) Get(userId string) (*model.Status, *model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
func (s *OpenTracingLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.GetByIds")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -6260,7 +6260,7 @@ func (s *OpenTracingLayerStatusStore) GetByIds(userIds []string) ([]*model.Statu
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
func (s *OpenTracingLayerStatusStore) GetTotalActiveUsersCount() (int64, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.GetTotalActiveUsersCount")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -6278,7 +6278,7 @@ func (s *OpenTracingLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) ResetAll() *model.AppError {
|
||||
func (s *OpenTracingLayerStatusStore) ResetAll() error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.ResetAll")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -6296,7 +6296,7 @@ func (s *OpenTracingLayerStatusStore) ResetAll() *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
func (s *OpenTracingLayerStatusStore) SaveOrUpdate(status *model.Status) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.SaveOrUpdate")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -6314,7 +6314,7 @@ func (s *OpenTracingLayerStatusStore) SaveOrUpdate(status *model.Status) *model.
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
func (s *OpenTracingLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "StatusStore.UpdateLastActivityAt")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
@@ -4510,39 +4510,123 @@ func (s *RetryLayerSessionStore) UpdateRoles(userId string, roles string) (strin
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
func (s *RetryLayerStatusStore) Get(userId string) (*model.Status, error) {
|
||||
|
||||
return s.StatusStore.Get(userId)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.StatusStore.Get(userId)
|
||||
if err == nil {
|
||||
return result, err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
func (s *RetryLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
||||
|
||||
return s.StatusStore.GetByIds(userIds)
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.StatusStore.GetByIds(userIds)
|
||||
if err == nil {
|
||||
return result, err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
func (s *RetryLayerStatusStore) GetTotalActiveUsersCount() (int64, error) {
|
||||
|
||||
return s.StatusStore.GetTotalActiveUsersCount()
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.StatusStore.GetTotalActiveUsersCount()
|
||||
if err == nil {
|
||||
return result, err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return result, err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) ResetAll() *model.AppError {
|
||||
func (s *RetryLayerStatusStore) ResetAll() error {
|
||||
|
||||
return s.StatusStore.ResetAll()
|
||||
tries := 0
|
||||
for {
|
||||
err := s.StatusStore.ResetAll()
|
||||
if err == nil {
|
||||
return err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
func (s *RetryLayerStatusStore) SaveOrUpdate(status *model.Status) error {
|
||||
|
||||
return s.StatusStore.SaveOrUpdate(status)
|
||||
tries := 0
|
||||
for {
|
||||
err := s.StatusStore.SaveOrUpdate(status)
|
||||
if err == nil {
|
||||
return err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
func (s *RetryLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
||||
|
||||
return s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt)
|
||||
tries := 0
|
||||
for {
|
||||
err := s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt)
|
||||
if err == nil {
|
||||
return err
|
||||
}
|
||||
if !isRepeatableError(err) {
|
||||
return err
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,16 @@ package sqlstore
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"net/http"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
)
|
||||
|
||||
const (
|
||||
MISSING_STATUS_ERROR = "store.sql_status.get.missing.app_error"
|
||||
)
|
||||
|
||||
type SqlStatusStore struct {
|
||||
SqlStore
|
||||
}
|
||||
@@ -40,22 +37,22 @@ func (s SqlStatusStore) createIndexesIfNotExists() {
|
||||
s.CreateIndexIfNotExists("idx_status_status", "Status", "Status")
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
func (s SqlStatusStore) SaveOrUpdate(status *model.Status) error {
|
||||
if err := s.GetReplica().SelectOne(&model.Status{}, "SELECT * FROM Status WHERE UserId = :UserId", map[string]interface{}{"UserId": status.UserId}); err == nil {
|
||||
if _, err := s.GetMaster().Update(status); err != nil {
|
||||
return model.NewAppError("SqlStatusStore.SaveOrUpdate", "store.sql_status.update.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return errors.Wrap(err, "failed to update Status")
|
||||
}
|
||||
} else {
|
||||
if err := s.GetMaster().Insert(status); err != nil {
|
||||
if !(strings.Contains(err.Error(), "for key 'PRIMARY'") && strings.Contains(err.Error(), "Duplicate entry")) {
|
||||
return model.NewAppError("SqlStatusStore.SaveOrUpdate", "store.sql_status.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return errors.Wrap(err, "failed in save Status")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
func (s SqlStatusStore) Get(userId string) (*model.Status, error) {
|
||||
var status model.Status
|
||||
|
||||
if err := s.GetReplica().SelectOne(&status,
|
||||
@@ -66,72 +63,61 @@ func (s SqlStatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
WHERE
|
||||
UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, model.NewAppError("SqlStatusStore.Get", MISSING_STATUS_ERROR, nil, err.Error(), http.StatusNotFound)
|
||||
return nil, store.NewErrNotFound("Status", fmt.Sprintf("userId=%s", userId))
|
||||
}
|
||||
return nil, model.NewAppError("SqlStatusStore.Get", "store.sql_status.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to get Status with userId=%s", userId)
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
|
||||
failure := func(err error) *model.AppError {
|
||||
return model.NewAppError(
|
||||
"SqlStatusStore.GetByIds",
|
||||
"store.sql_status.get.app_error",
|
||||
nil,
|
||||
err.Error(),
|
||||
http.StatusInternalServerError,
|
||||
)
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("UserId, Status, Manual, LastActivityAt").
|
||||
From("Status").
|
||||
Where(sq.Eq{"UserId": userIds})
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, failure(err)
|
||||
return nil, errors.Wrap(err, "status_tosql")
|
||||
}
|
||||
rows, err := s.GetReplica().Db.Query(queryString, args...)
|
||||
if err != nil {
|
||||
return nil, failure(err)
|
||||
return nil, errors.Wrap(err, "failed to find Statuses")
|
||||
}
|
||||
var statuses []*model.Status
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var status model.Status
|
||||
if err = rows.Scan(&status.UserId, &status.Status, &status.Manual, &status.LastActivityAt); err != nil {
|
||||
return nil, failure(err)
|
||||
return nil, errors.Wrap(err, "unable to scan from rows")
|
||||
}
|
||||
statuses = append(statuses, &status)
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
return nil, failure(err)
|
||||
return nil, errors.Wrap(err, "failed while iterating over rows")
|
||||
}
|
||||
|
||||
return statuses, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) ResetAll() *model.AppError {
|
||||
func (s SqlStatusStore) ResetAll() error {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET Status = :Status WHERE Manual = false", map[string]interface{}{"Status": model.STATUS_OFFLINE}); err != nil {
|
||||
return model.NewAppError("SqlStatusStore.ResetAll", "store.sql_status.reset_all.app_error", nil, "", http.StatusInternalServerError)
|
||||
return errors.Wrap(err, "failed to update Statuses")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
func (s SqlStatusStore) GetTotalActiveUsersCount() (int64, error) {
|
||||
time := model.GetMillis() - (1000 * 60 * 60 * 24)
|
||||
count, err := s.GetReplica().SelectInt("SELECT COUNT(UserId) FROM Status WHERE LastActivityAt > :Time", map[string]interface{}{"Time": time})
|
||||
if err != nil {
|
||||
return count, model.NewAppError("SqlStatusStore.GetTotalActiveUsersCount", "store.sql_status.get_total_active_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return count, errors.Wrap(err, "failed to count active users")
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
func (s SqlStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
||||
if _, err := s.GetMaster().Exec("UPDATE Status SET LastActivityAt = :Time WHERE UserId = :UserId", map[string]interface{}{"UserId": userId, "Time": lastActivityAt}); err != nil {
|
||||
return model.NewAppError("SqlStatusStore.UpdateLastActivityAt", "store.sql_status.update_last_activity_at.app_error", nil, "", http.StatusInternalServerError)
|
||||
return errors.Wrapf(err, "failed to update last activity for userId=%s", userId)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -525,12 +525,12 @@ type EmojiStore interface {
|
||||
}
|
||||
|
||||
type StatusStore interface {
|
||||
SaveOrUpdate(status *model.Status) *model.AppError
|
||||
Get(userId string) (*model.Status, *model.AppError)
|
||||
GetByIds(userIds []string) ([]*model.Status, *model.AppError)
|
||||
ResetAll() *model.AppError
|
||||
GetTotalActiveUsersCount() (int64, *model.AppError)
|
||||
UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError
|
||||
SaveOrUpdate(status *model.Status) error
|
||||
Get(userId string) (*model.Status, error)
|
||||
GetByIds(userIds []string) ([]*model.Status, error)
|
||||
ResetAll() error
|
||||
GetTotalActiveUsersCount() (int64, error)
|
||||
UpdateLastActivityAt(userId string, lastActivityAt int64) error
|
||||
}
|
||||
|
||||
type FileInfoStore interface {
|
||||
|
||||
@@ -15,7 +15,7 @@ type StatusStore struct {
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: userId
|
||||
func (_m *StatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
func (_m *StatusStore) Get(userId string) (*model.Status, error) {
|
||||
ret := _m.Called(userId)
|
||||
|
||||
var r0 *model.Status
|
||||
@@ -27,20 +27,18 @@ func (_m *StatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(userId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetByIds provides a mock function with given fields: userIds
|
||||
func (_m *StatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
func (_m *StatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
||||
ret := _m.Called(userIds)
|
||||
|
||||
var r0 []*model.Status
|
||||
@@ -52,20 +50,18 @@ func (_m *StatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppEr
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func([]string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]string) error); ok {
|
||||
r1 = rf(userIds)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetTotalActiveUsersCount provides a mock function with given fields:
|
||||
func (_m *StatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
func (_m *StatusStore) GetTotalActiveUsersCount() (int64, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 int64
|
||||
@@ -75,61 +71,53 @@ func (_m *StatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
r0 = ret.Get(0).(int64)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ResetAll provides a mock function with given fields:
|
||||
func (_m *StatusStore) ResetAll() *model.AppError {
|
||||
func (_m *StatusStore) ResetAll() error {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// SaveOrUpdate provides a mock function with given fields: status
|
||||
func (_m *StatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
func (_m *StatusStore) SaveOrUpdate(status *model.Status) error {
|
||||
ret := _m.Called(status)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(*model.Status) *model.AppError); ok {
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(*model.Status) error); ok {
|
||||
r0 = rf(status)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastActivityAt provides a mock function with given fields: userId, lastActivityAt
|
||||
func (_m *StatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
func (_m *StatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
||||
ret := _m.Called(userId, lastActivityAt)
|
||||
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, int64) error); ok {
|
||||
r0 = rf(userId, lastActivityAt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
|
||||
@@ -5628,7 +5628,7 @@ func (s *TimerLayerSessionStore) UpdateRoles(userId string, roles string) (strin
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) Get(userId string) (*model.Status, *model.AppError) {
|
||||
func (s *TimerLayerStatusStore) Get(userId string) (*model.Status, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.StatusStore.Get(userId)
|
||||
@@ -5644,7 +5644,7 @@ func (s *TimerLayerStatusStore) Get(userId string) (*model.Status, *model.AppErr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, *model.AppError) {
|
||||
func (s *TimerLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.StatusStore.GetByIds(userIds)
|
||||
@@ -5660,7 +5660,7 @@ func (s *TimerLayerStatusStore) GetByIds(userIds []string) ([]*model.Status, *mo
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.AppError) {
|
||||
func (s *TimerLayerStatusStore) GetTotalActiveUsersCount() (int64, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.StatusStore.GetTotalActiveUsersCount()
|
||||
@@ -5676,7 +5676,7 @@ func (s *TimerLayerStatusStore) GetTotalActiveUsersCount() (int64, *model.AppErr
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) ResetAll() *model.AppError {
|
||||
func (s *TimerLayerStatusStore) ResetAll() error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.StatusStore.ResetAll()
|
||||
@@ -5692,7 +5692,7 @@ func (s *TimerLayerStatusStore) ResetAll() *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) SaveOrUpdate(status *model.Status) *model.AppError {
|
||||
func (s *TimerLayerStatusStore) SaveOrUpdate(status *model.Status) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.StatusStore.SaveOrUpdate(status)
|
||||
@@ -5708,7 +5708,7 @@ func (s *TimerLayerStatusStore) SaveOrUpdate(status *model.Status) *model.AppErr
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TimerLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) *model.AppError {
|
||||
func (s *TimerLayerStatusStore) UpdateLastActivityAt(userId string, lastActivityAt int64) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.StatusStore.UpdateLastActivityAt(userId, lastActivityAt)
|
||||
|
||||
Ссылка в новой задаче
Block a user