[MM-47002] Fix new private channels not showing up in least active channels insights (#21031)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
943fa33f64
Коммит
2ea14ef395
@@ -4367,7 +4367,7 @@ func (s SqlChannelStore) GetTopInactiveChannelsForTeamSince(teamID string, userI
|
||||
FROM
|
||||
Channels
|
||||
LEFT JOIN Posts on Posts.ChannelId = Channels.Id AND Posts.Type = '' AND Posts.CreateAt > ? AND Posts.DeleteAt = 0
|
||||
LEFT JOIN ChannelMembers on Posts.ChannelId = ChannelMembers.ChannelId
|
||||
LEFT JOIN ChannelMembers on Channels.Id = ChannelMembers.ChannelId
|
||||
WHERE
|
||||
Channels.TeamId = ?
|
||||
AND Channels.CreateAt < ?
|
||||
@@ -4416,7 +4416,7 @@ func (s SqlChannelStore) GetTopInactiveChannelsForUserSince(teamID string, userI
|
||||
FROM
|
||||
Channels
|
||||
LEFT JOIN Posts on Posts.ChannelId = Channels.Id AND Posts.Type = '' AND Posts.CreateAt > ? AND Posts.DeleteAt = 0
|
||||
LEFT JOIN ChannelMembers on Posts.ChannelId = ChannelMembers.ChannelId
|
||||
LEFT JOIN ChannelMembers on Channels.Id = ChannelMembers.ChannelId
|
||||
WHERE
|
||||
Channels.DeleteAt = 0
|
||||
AND Channels.CreateAt < ?
|
||||
|
||||
@@ -8007,6 +8007,16 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) {
|
||||
channelPrivate, nErr := ss.Channel().Save(&c3, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
// create private channel with post
|
||||
c3NoPost := model.Channel{}
|
||||
c3NoPost.TeamId = team.Id
|
||||
c3NoPost.DisplayName = "Channel3" + model.NewId()
|
||||
c3NoPost.Name = NewTestId()
|
||||
c3NoPost.Type = model.ChannelTypePrivate
|
||||
c3NoPost.CreateAt = 1
|
||||
channelPrivateNoPost, nErr := ss.Channel().Save(&c3NoPost, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
// create dm channel
|
||||
u1 := model.User{}
|
||||
u1.Email = MakeEmail()
|
||||
@@ -8029,6 +8039,9 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) {
|
||||
cm1 := &model.ChannelMember{ChannelId: channelPrivate.Id, UserId: u1.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
_, err = ss.Channel().SaveMember(cm1)
|
||||
require.NoError(t, err)
|
||||
cm1NoPost := &model.ChannelMember{ChannelId: channelPrivateNoPost.Id, UserId: u1.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
_, err = ss.Channel().SaveMember(cm1NoPost)
|
||||
require.NoError(t, err)
|
||||
cm1Public := &model.ChannelMember{ChannelId: channelPublic1.Id, UserId: u1.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
_, err = ss.Channel().SaveMember(cm1Public)
|
||||
require.NoError(t, err)
|
||||
@@ -8085,25 +8098,27 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) {
|
||||
t.Run("top inactive channels for team - u1 ", func(t *testing.T) {
|
||||
topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForTeamSince(team.Id, u1.Id, 2, 0, 10)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, topInactiveChannels.Items, 3)
|
||||
require.Equal(t, topInactiveChannels.Items[0].ID, channelSaved0.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[0].LastActivityAt, postToCheckLastUpdateAt.CreateAt)
|
||||
require.Equal(t, topInactiveChannels.Items[1].ID, channelPrivate.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[2].ID, channelPublic1.Id)
|
||||
require.Len(t, topInactiveChannels.Items, 4)
|
||||
require.Equal(t, topInactiveChannels.Items[0].ID, channelPrivateNoPost.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[1].ID, channelSaved0.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[1].LastActivityAt, postToCheckLastUpdateAt.CreateAt)
|
||||
require.Equal(t, topInactiveChannels.Items[2].ID, channelPrivate.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[3].ID, channelPublic1.Id)
|
||||
// test bot posts are counted
|
||||
require.Equal(t, topInactiveChannels.Items[2].MessageCount, int64(4))
|
||||
require.Equal(t, topInactiveChannels.Items[3].MessageCount, int64(4))
|
||||
|
||||
// participants
|
||||
require.Equal(t, topInactiveChannels.Items[1].Participants[0], u1.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[2].Participants[0], u1.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[3].Participants[0], u1.Id)
|
||||
})
|
||||
|
||||
t.Run("top inactive channels for user - u1 ", func(t *testing.T) {
|
||||
topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForUserSince(team.Id, u1.Id, 2, 0, 10)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, topInactiveChannels.Items, 2)
|
||||
require.Equal(t, topInactiveChannels.Items[0].ID, channelPrivate.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[1].ID, channelPublic1.Id)
|
||||
require.Len(t, topInactiveChannels.Items, 3)
|
||||
require.Equal(t, topInactiveChannels.Items[0].ID, channelPrivateNoPost.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[1].ID, channelPrivate.Id)
|
||||
require.Equal(t, topInactiveChannels.Items[2].ID, channelPublic1.Id)
|
||||
})
|
||||
|
||||
// for u2
|
||||
|
||||
Ссылка в новой задаче
Block a user