Migrate Channel.GetChannelsBatchForIndexing to Sync by default (#11134)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d1569c48d2
Коммит
242c4f2c66
@@ -2608,33 +2608,30 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, limit int) store.StoreChannel {
|
func (s SqlChannelStore) GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query :=
|
||||||
var channels []*model.Channel
|
`SELECT
|
||||||
_, err1 := s.GetSearchReplica().Select(&channels,
|
*
|
||||||
`SELECT
|
FROM
|
||||||
*
|
Channels
|
||||||
FROM
|
WHERE
|
||||||
Channels
|
Type = 'O'
|
||||||
WHERE
|
AND
|
||||||
Type = 'O'
|
CreateAt >= :StartTime
|
||||||
AND
|
AND
|
||||||
CreateAt >= :StartTime
|
CreateAt < :EndTime
|
||||||
AND
|
ORDER BY
|
||||||
CreateAt < :EndTime
|
CreateAt
|
||||||
ORDER BY
|
LIMIT
|
||||||
CreateAt
|
:NumChannels`
|
||||||
LIMIT
|
|
||||||
:NumChannels`,
|
|
||||||
map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumChannels": limit})
|
|
||||||
|
|
||||||
if err1 != nil {
|
var channels []*model.Channel
|
||||||
result.Err = model.NewAppError("SqlChannelStore.GetChannelsBatchForIndexing", "store.sql_channel.get_channels_batch_for_indexing.get.app_error", nil, err1.Error(), http.StatusInternalServerError)
|
_, err := s.GetSearchReplica().Select(&channels, query, map[string]interface{}{"StartTime": startTime, "EndTime": endTime, "NumChannels": limit})
|
||||||
return
|
if err != nil {
|
||||||
}
|
return nil, model.NewAppError("SqlChannelStore.GetChannelsBatchForIndexing", "store.sql_channel.get_channels_batch_for_indexing.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
result.Data = channels
|
return channels, nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) store.StoreChannel {
|
func (s SqlChannelStore) UserBelongsToChannels(userId string, channelIds []string) store.StoreChannel {
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ type ChannelStore interface {
|
|||||||
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||||
GetChannelMembersForExport(userId string, teamId string) StoreChannel
|
GetChannelMembersForExport(userId string, teamId string) StoreChannel
|
||||||
RemoveAllDeactivatedMembers(channelId string) StoreChannel
|
RemoveAllDeactivatedMembers(channelId string) StoreChannel
|
||||||
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) StoreChannel
|
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
|
||||||
UserBelongsToChannels(userId string, channelIds []string) StoreChannel
|
UserBelongsToChannels(userId string, channelIds []string) StoreChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3650,18 +3650,18 @@ func testChannelStoreGetChannelsBatchForIndexing(t *testing.T, ss store.Store) {
|
|||||||
endTime := c6.CreateAt
|
endTime := c6.CreateAt
|
||||||
|
|
||||||
// First and last channel should be outside the range
|
// First and last channel should be outside the range
|
||||||
res1 := <-ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 1000)
|
channels, err := ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 1000)
|
||||||
assert.Nil(t, res1.Err)
|
assert.Nil(t, err)
|
||||||
assert.ElementsMatch(t, []*model.Channel{c2, c3, c5}, res1.Data)
|
assert.ElementsMatch(t, []*model.Channel{c2, c3, c5}, channels)
|
||||||
|
|
||||||
// Update the endTime, last channel should be in
|
// Update the endTime, last channel should be in
|
||||||
endTime = model.GetMillis()
|
endTime = model.GetMillis()
|
||||||
res2 := <-ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 1000)
|
channels, err = ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 1000)
|
||||||
assert.Nil(t, res2.Err)
|
assert.Nil(t, err)
|
||||||
assert.ElementsMatch(t, []*model.Channel{c2, c3, c5, c6}, res2.Data)
|
assert.ElementsMatch(t, []*model.Channel{c2, c3, c5, c6}, channels)
|
||||||
|
|
||||||
// Testing the limit
|
// Testing the limit
|
||||||
res3 := <-ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 2)
|
channels, err = ss.Channel().GetChannelsBatchForIndexing(startTime, endTime, 2)
|
||||||
assert.Nil(t, res3.Err)
|
assert.Nil(t, err)
|
||||||
assert.ElementsMatch(t, []*model.Channel{c2, c3}, res3.Data)
|
assert.ElementsMatch(t, []*model.Channel{c2, c3}, channels)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,19 +441,28 @@ func (_m *ChannelStore) GetChannels(teamId string, userId string, includeDeleted
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetChannelsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit
|
// GetChannelsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit
|
||||||
func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) store.StoreChannel {
|
func (_m *ChannelStore) GetChannelsBatchForIndexing(startTime int64, endTime int64, limit int) ([]*model.Channel, *model.AppError) {
|
||||||
ret := _m.Called(startTime, endTime, limit)
|
ret := _m.Called(startTime, endTime, limit)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 []*model.Channel
|
||||||
if rf, ok := ret.Get(0).(func(int64, int64, int) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(int64, int64, int) []*model.Channel); ok {
|
||||||
r0 = rf(startTime, endTime, limit)
|
r0 = rf(startTime, endTime, limit)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).([]*model.Channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(int64, int64, int) *model.AppError); ok {
|
||||||
|
r1 = rf(startTime, endTime, limit)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChannelsByIds provides a mock function with given fields: channelIds
|
// GetChannelsByIds provides a mock function with given fields: channelIds
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user