MM-36743: adds last_root_post_at in channels table (#18366)

* MM-36743: adds last_root_post_at in channels table

Channel recency for CRT users should not count replies,
this commit solves that issue by adding a new column to the channels
table: LastRootPostAt.
With that new info CRT users can have recent channels to work as
expected.

* Adds the 'LastRootPostAt' to the SQL scripts

* Fixes tests

* Adds LastRootPostAt migration to v6.1

* Fixes index

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Kyriakos Z
2021-10-13 22:20:44 +03:00
коммит произвёл GitHub
родитель ff10bf1068
Коммит 4b85f9ee6a
6 изменённых файлов: 72 добавлений и 24 удалений

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

@@ -4218,6 +4218,7 @@ func testChannelStoreUpdateLastViewedAt(t *testing.T, ss store.Store) {
o1.Type = model.ChannelTypeOpen
o1.TotalMsgCount = 25
o1.LastPostAt = 12345
o1.LastRootPostAt = 12345
_, nErr := ss.Channel().Save(&o1, -1)
require.NoError(t, nErr)
@@ -4235,6 +4236,7 @@ func testChannelStoreUpdateLastViewedAt(t *testing.T, ss store.Store) {
o2.Type = model.ChannelTypeOpen
o2.TotalMsgCount = 26
o2.LastPostAt = 123456
o2.LastRootPostAt = 123456
_, nErr = ss.Channel().Save(&o2, -1)
require.NoError(t, nErr)
@@ -6445,24 +6447,25 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) {
_, execerr = s.GetMaster().ExecNoTimeout(`
INSERT INTO
Channels(Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, TotalMsgCountRoot)
Channels(Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, LastRootPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, TotalMsgCountRoot)
VALUES
(:Id, :CreateAt, :UpdateAt, :DeleteAt, :TeamId, :Type, :DisplayName, :Name, :Header, :Purpose, :LastPostAt, :TotalMsgCount, :ExtraUpdateAt, :CreatorId, 0);
(:Id, :CreateAt, :UpdateAt, :DeleteAt, :TeamId, :Type, :DisplayName, :Name, :Header, :Purpose, :LastPostAt, :LastRootPostAt, :TotalMsgCount, :ExtraUpdateAt, :CreatorId, 0);
`, map[string]interface{}{
"Id": o3.Id,
"CreateAt": o3.CreateAt,
"UpdateAt": o3.UpdateAt,
"DeleteAt": o3.DeleteAt,
"TeamId": o3.TeamId,
"Type": o3.Type,
"DisplayName": o3.DisplayName,
"Name": o3.Name,
"Header": o3.Header,
"Purpose": o3.Purpose,
"LastPostAt": o3.LastPostAt,
"TotalMsgCount": o3.TotalMsgCount,
"ExtraUpdateAt": o3.ExtraUpdateAt,
"CreatorId": o3.CreatorId,
"Id": o3.Id,
"CreateAt": o3.CreateAt,
"UpdateAt": o3.UpdateAt,
"DeleteAt": o3.DeleteAt,
"TeamId": o3.TeamId,
"Type": o3.Type,
"DisplayName": o3.DisplayName,
"Name": o3.Name,
"Header": o3.Header,
"Purpose": o3.Purpose,
"LastPostAt": o3.LastPostAt,
"LastRootPostAt": o3.LastRootPostAt,
"TotalMsgCount": o3.TotalMsgCount,
"ExtraUpdateAt": o3.ExtraUpdateAt,
"CreatorId": o3.CreatorId,
})
require.NoError(t, execerr)