diff --git a/app/config.go b/app/config.go index cebb40d654..3537ff7a44 100644 --- a/app/config.go +++ b/app/config.go @@ -243,10 +243,10 @@ func (a *App) ensureInstallationDate() error { return nil } - result := <-a.Srv.Store.User().InferSystemInstallDate() + installDate, err := a.Srv.Store.User().InferSystemInstallDate() var installationDate int64 - if result.Err == nil && result.Data.(int64) > 0 { - installationDate = result.Data.(int64) + if err == nil && installDate > 0 { + installationDate = installDate } else { installationDate = utils.MillisFromTime(time.Now()) } diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index 9d1593bc8b..2d12da48e0 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -1488,15 +1488,13 @@ func (us SqlUserStore) ClearAllCustomRoleAssignments() *model.AppError { return nil } -func (us SqlUserStore) InferSystemInstallDate() store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - createAt, err := us.GetReplica().SelectInt("SELECT CreateAt FROM Users WHERE CreateAt IS NOT NULL ORDER BY CreateAt ASC LIMIT 1") - if err != nil { - result.Err = model.NewAppError("SqlUserStore.GetSystemInstallDate", "store.sql_user.get_system_install_date.app_error", nil, err.Error(), http.StatusInternalServerError) - return - } - result.Data = createAt - }) +func (us SqlUserStore) InferSystemInstallDate() (int64, *model.AppError) { + createAt, err := us.GetReplica().SelectInt("SELECT CreateAt FROM Users WHERE CreateAt IS NOT NULL ORDER BY CreateAt ASC LIMIT 1") + if err != nil { + return 0, model.NewAppError("SqlUserStore.GetSystemInstallDate", "store.sql_user.get_system_install_date.app_error", nil, err.Error(), http.StatusInternalServerError) + } + + return createAt, nil } func (us SqlUserStore) GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) { diff --git a/store/store.go b/store/store.go index 4947431323..c435af733f 100644 --- a/store/store.go +++ b/store/store.go @@ -301,7 +301,7 @@ type UserStore interface { GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) GetEtagForProfilesNotInTeam(teamId string) StoreChannel ClearAllCustomRoleAssignments() *model.AppError - InferSystemInstallDate() StoreChannel + InferSystemInstallDate() (int64, *model.AppError) GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError) GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) Count(options model.UserCountOptions) (int64, *model.AppError) diff --git a/store/storetest/mocks/UserStore.go b/store/storetest/mocks/UserStore.go index 4e71b52f68..a703d5a950 100644 --- a/store/storetest/mocks/UserStore.go +++ b/store/storetest/mocks/UserStore.go @@ -820,19 +820,26 @@ func (_m *UserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, li } // InferSystemInstallDate provides a mock function with given fields: -func (_m *UserStore) InferSystemInstallDate() store.StoreChannel { +func (_m *UserStore) InferSystemInstallDate() (int64, *model.AppError) { ret := _m.Called() - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func() store.StoreChannel); ok { + var r0 int64 + if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(int64) + } + + var r1 *model.AppError + if rf, ok := ret.Get(1).(func() *model.AppError); ok { + r1 = rf() + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.AppError) } } - return r0 + return r0, r1 } // InvalidatProfileCacheForUser provides a mock function with given fields: userId