Migrate Plugin.List to Sync by default (#11582)

This commit is contained in:
Phillip Ahereza
2019-07-08 18:35:33 +03:00
committed by Saturnino Abril
parent 673ed02a0d
commit ff5b221598
4 changed files with 28 additions and 21 deletions

View File

@@ -160,7 +160,7 @@ func (ps SqlPluginStore) DeleteAllExpired() store.StoreChannel {
})
}
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) store.StoreChannel {
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) ([]string, *model.AppError) {
if limit <= 0 {
limit = DEFAULT_PLUGIN_KEY_FETCH_LIMIT
}
@@ -169,13 +169,11 @@ func (ps SqlPluginStore) List(pluginId string, offset int, limit int) store.Stor
offset = 0
}
return store.Do(func(result *store.StoreResult) {
var keys []string
_, err := ps.GetReplica().Select(&keys, "SELECT PKey FROM PluginKeyValueStore WHERE PluginId = :PluginId order by PKey limit :Limit offset :Offset", map[string]interface{}{"PluginId": pluginId, "Limit": limit, "Offset": offset})
if err != nil {
result.Err = model.NewAppError("SqlPluginStore.List", "store.sql_plugin_store.list.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
} else {
result.Data = keys
}
})
var keys []string
_, err := ps.GetReplica().Select(&keys, "SELECT PKey FROM PluginKeyValueStore WHERE PluginId = :PluginId order by PKey limit :Limit offset :Offset", map[string]interface{}{"PluginId": pluginId, "Limit": limit, "Offset": offset})
if err != nil {
return nil, model.NewAppError("SqlPluginStore.List", "store.sql_plugin_store.list.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
}
return keys, nil
}

View File

@@ -541,7 +541,7 @@ type PluginStore interface {
Delete(pluginId, key string) StoreChannel
DeleteAllForPlugin(PluginId string) StoreChannel
DeleteAllExpired() StoreChannel
List(pluginId string, page, perPage int) StoreChannel
List(pluginId string, page, perPage int) ([]string, *model.AppError)
}
type RoleStore interface {

View File

@@ -110,19 +110,28 @@ func (_m *PluginStore) Get(pluginId string, key string) (*model.PluginKeyValue,
}
// List provides a mock function with given fields: pluginId, page, perPage
func (_m *PluginStore) List(pluginId string, page int, perPage int) store.StoreChannel {
func (_m *PluginStore) List(pluginId string, page int, perPage int) ([]string, *model.AppError) {
ret := _m.Called(pluginId, page, perPage)
var r0 store.StoreChannel
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
var r0 []string
if rf, ok := ret.Get(0).(func(string, int, int) []string); ok {
r0 = rf(pluginId, page, perPage)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
r0 = ret.Get(0).([]string)
}
}
return r0
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
r1 = rf(pluginId, page, perPage)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// SaveOrUpdate provides a mock function with given fields: keyVal