Add paging to the GET /emojis endpoint (#6802)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
02335ddad4
Коммит
f54aee1ef5
@@ -150,7 +150,7 @@ func (es SqlEmojiStore) GetByName(name string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) GetAll() StoreChannel {
|
||||
func (es SqlEmojiStore) GetList(offset, limit int) StoreChannel {
|
||||
storeChannel := make(StoreChannel, 1)
|
||||
|
||||
go func() {
|
||||
@@ -164,8 +164,9 @@ func (es SqlEmojiStore) GetAll() StoreChannel {
|
||||
FROM
|
||||
Emoji
|
||||
WHERE
|
||||
DeleteAt = 0`); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlEmojiStore.Get", "store.sql_emoji.get_all.app_error", nil, err.Error())
|
||||
DeleteAt = 0
|
||||
LIMIT :Limit OFFSET :Offset`, map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil {
|
||||
result.Err = model.NewAppError("SqlEmojiStore.GetList", "store.sql_emoji.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = emoji
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func TestEmojiGetByName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmojiGetAll(t *testing.T) {
|
||||
func TestEmojiGetList(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
emojis := []model.Emoji{
|
||||
@@ -153,7 +153,7 @@ func TestEmojiGetAll(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
if result := <-store.Emoji().GetAll(); result.Err != nil {
|
||||
if result := <-store.Emoji().GetList(0, 100); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
for _, emoji := range emojis {
|
||||
|
||||
@@ -349,7 +349,7 @@ type EmojiStore interface {
|
||||
Save(emoji *model.Emoji) StoreChannel
|
||||
Get(id string, allowFromCache bool) StoreChannel
|
||||
GetByName(name string) StoreChannel
|
||||
GetAll() StoreChannel
|
||||
GetList(offset, limit int) StoreChannel
|
||||
Delete(id string, time int64) StoreChannel
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user