Migrate User.InferSystemInstallDate to sync by default (#11505)

* Migrate User.InferSystemInstallDate to sync by default

* Change var name
Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-07-08 02:46:31 -04:00
коммит произвёл Miguel de la Cruz
родитель 7663c5b00e
Коммит e908165fe3
4 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@@ -243,10 +243,10 @@ func (a *App) ensureInstallationDate() error {
return nil return nil
} }
result := <-a.Srv.Store.User().InferSystemInstallDate() installDate, err := a.Srv.Store.User().InferSystemInstallDate()
var installationDate int64 var installationDate int64
if result.Err == nil && result.Data.(int64) > 0 { if err == nil && installDate > 0 {
installationDate = result.Data.(int64) installationDate = installDate
} else { } else {
installationDate = utils.MillisFromTime(time.Now()) installationDate = utils.MillisFromTime(time.Now())
} }

Просмотреть файл

@@ -1488,15 +1488,13 @@ func (us SqlUserStore) ClearAllCustomRoleAssignments() *model.AppError {
return nil return nil
} }
func (us SqlUserStore) InferSystemInstallDate() store.StoreChannel { func (us SqlUserStore) InferSystemInstallDate() (int64, *model.AppError) {
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")
createAt, err := us.GetReplica().SelectInt("SELECT CreateAt FROM Users WHERE CreateAt IS NOT NULL ORDER BY CreateAt ASC LIMIT 1") if err != nil {
if err != nil { return 0, model.NewAppError("SqlUserStore.GetSystemInstallDate", "store.sql_user.get_system_install_date.app_error", nil, err.Error(), http.StatusInternalServerError)
result.Err = model.NewAppError("SqlUserStore.GetSystemInstallDate", "store.sql_user.get_system_install_date.app_error", nil, err.Error(), http.StatusInternalServerError) }
return
} return createAt, nil
result.Data = createAt
})
} }
func (us SqlUserStore) GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) { func (us SqlUserStore) GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) {

Просмотреть файл

@@ -301,7 +301,7 @@ type UserStore interface {
GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) GetProfilesNotInTeam(teamId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
GetEtagForProfilesNotInTeam(teamId string) StoreChannel GetEtagForProfilesNotInTeam(teamId string) StoreChannel
ClearAllCustomRoleAssignments() *model.AppError ClearAllCustomRoleAssignments() *model.AppError
InferSystemInstallDate() StoreChannel InferSystemInstallDate() (int64, *model.AppError)
GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError) GetAllAfter(limit int, afterId string) ([]*model.User, *model.AppError)
GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError) GetUsersBatchForIndexing(startTime, endTime int64, limit int) ([]*model.UserForIndexing, *model.AppError)
Count(options model.UserCountOptions) (int64, *model.AppError) Count(options model.UserCountOptions) (int64, *model.AppError)

Просмотреть файл

@@ -820,19 +820,26 @@ func (_m *UserStore) GetUsersBatchForIndexing(startTime int64, endTime int64, li
} }
// InferSystemInstallDate provides a mock function with given fields: // InferSystemInstallDate provides a mock function with given fields:
func (_m *UserStore) InferSystemInstallDate() store.StoreChannel { func (_m *UserStore) InferSystemInstallDate() (int64, *model.AppError) {
ret := _m.Called() ret := _m.Called()
var r0 store.StoreChannel var r0 int64
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok { if rf, ok := ret.Get(0).(func() int64); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { r0 = ret.Get(0).(int64)
r0 = ret.Get(0).(store.StoreChannel) }
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 // InvalidatProfileCacheForUser provides a mock function with given fields: userId