Fix sampledata reset LastPostAt when the channels are empty (#9295)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a63c68be35
Коммит
f9dbea6d86
@@ -1924,7 +1924,14 @@ func (s SqlChannelStore) ClearAllCustomRoleAssignments() store.StoreChannel {
|
|||||||
|
|
||||||
func (s SqlChannelStore) ResetLastPostAt() store.StoreChannel {
|
func (s SqlChannelStore) ResetLastPostAt() store.StoreChannel {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
return store.Do(func(result *store.StoreResult) {
|
||||||
if _, err := s.GetMaster().Exec("UPDATE Channels SET LastPostAt = (SELECT UpdateAt FROM Posts WHERE ChannelId = Channels.Id ORDER BY UpdateAt DESC LIMIT 1);"); err != nil {
|
var query string
|
||||||
|
if s.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
|
query = "UPDATE Channels SET LastPostAt = COALESCE((SELECT UpdateAt FROM Posts WHERE ChannelId = Channels.Id ORDER BY UpdateAt DESC LIMIT 1), Channels.CreateAt);"
|
||||||
|
} else {
|
||||||
|
query = "UPDATE Channels SET LastPostAt = IFNULL((SELECT UpdateAt FROM Posts WHERE ChannelId = Channels.Id ORDER BY UpdateAt DESC LIMIT 1), Channels.CreateAt);"
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := s.GetMaster().Exec(query); err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.ResetLastPostAt", "store.sql_channel.reset_last_post_at.app_error", nil, err.Error(), http.StatusInternalServerError)
|
result.Err = model.NewAppError("SqlChannelStore.ResetLastPostAt", "store.sql_channel.reset_last_post_at.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user