diff --git a/api4/insights_test.go b/api4/insights_test.go index dd1637a4a1..1eca69c72c 100644 --- a/api4/insights_test.go +++ b/api4/insights_test.go @@ -821,25 +821,68 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - // delete offtopic channel - which interferes with 'least' active channel results + // delete offtopic, town-square, th.basicchannel channel - which interferes with 'least' active channel results offTopicChannel, appErr := th.App.GetChannelByName(th.Context, "off-topic", th.BasicTeam.Id, false) require.Nil(t, appErr, "Expected nil, didn't receive nil") appErr = th.App.PermanentDeleteChannel(th.Context, offTopicChannel) require.Nil(t, appErr) + townSquareChannel, appErr := th.App.GetChannelByName(th.Context, "town-square", th.BasicTeam.Id, false) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, townSquareChannel) + require.Nil(t, appErr) + basicChannel, appErr := th.App.GetChannel(th.Context, th.BasicChannel.Id) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, basicChannel) + require.Nil(t, appErr) + basicChannel2, appErr := th.App.GetChannel(th.Context, th.BasicChannel2.Id) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, basicChannel2) + require.Nil(t, appErr) + basicPrivateChannel, appErr := th.App.GetChannel(th.Context, th.BasicPrivateChannel.Id) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, basicPrivateChannel) + require.Nil(t, appErr) th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional)) client := th.Client userId := th.BasicUser.Id - channel4 := th.CreatePublicChannel() - channel5 := th.CreatePrivateChannel() - channel6 := th.CreatePrivateChannel() + channel4Req := &model.Channel{ + DisplayName: "channel4", + Name: GenerateTestChannelName(), + Type: model.ChannelTypeOpen, + TeamId: th.BasicTeam.Id, + CreateAt: 1, + } + channel4, _, err := client.CreateChannel(channel4Req) + require.NoError(t, err) + + channel5Req := &model.Channel{ + DisplayName: "channel4", + Name: GenerateTestChannelName(), + Type: model.ChannelTypePrivate, + TeamId: th.BasicTeam.Id, + CreateAt: 1, + } + channel5, _, err := client.CreateChannel(channel5Req) + require.NoError(t, err) + + channel6Req := &model.Channel{ + DisplayName: "channel4", + Name: GenerateTestChannelName(), + Type: model.ChannelTypePrivate, + TeamId: th.BasicTeam.Id, + CreateAt: 1, + } + channel6, _, err := client.CreateChannel(channel6Req) + require.NoError(t, err) + th.App.AddUserToChannel(th.Context, th.BasicUser, channel4, false) th.App.AddUserToChannel(th.Context, th.BasicUser, channel5, false) th.App.AddUserToChannel(th.Context, th.BasicUser, channel6, false) - channelIDs := [6]string{th.BasicChannel.Id, th.BasicChannel2.Id, th.BasicPrivateChannel.Id, channel4.Id, channel5.Id, channel6.Id} + channelIDs := [3]string{channel4.Id, channel5.Id, channel6.Id} i := len(channelIDs) for _, channelID := range channelIDs { @@ -859,22 +902,19 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { ID: channel6.Id, MessageCount: 1}, {ID: channel5.Id, MessageCount: 2}, {ID: channel4.Id, MessageCount: 3}, - {ID: th.BasicPrivateChannel.Id, MessageCount: 4}, - {ID: th.BasicChannel2.Id, MessageCount: 5}, - {ID: th.BasicChannel.Id, MessageCount: 7}, } t.Run("get-top-inactive-channels-for-team-since", func(t *testing.T) { - topInactiveChannels, _, err := client.GetTopInactiveChannelsForTeamSince(teamId, model.TimeRangeToday, 0, 5) + topInactiveChannels, _, err := client.GetTopInactiveChannelsForTeamSince(teamId, model.TimeRangeToday, 0, 2) require.NoError(t, err) for i, channel := range topInactiveChannels.Items { assert.Equal(t, expectedTopChannels[i].ID, channel.ID) } - topInactiveChannels, _, err = client.GetTopInactiveChannelsForTeamSince(teamId, model.TimeRangeToday, 1, 5) + topInactiveChannels, _, err = client.GetTopInactiveChannelsForTeamSince(teamId, model.TimeRangeToday, 1, 2) require.NoError(t, err) - assert.Equal(t, th.BasicChannel.Id, topInactiveChannels.Items[0].ID) + assert.Equal(t, channel4.Id, topInactiveChannels.Items[0].ID) }) t.Run("get-top-channels-for-user-since exclude channels user is not member of", func(t *testing.T) { @@ -887,7 +927,7 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { th.RemoveUserFromChannel(th.BasicUser, excludedChannel) - topInactiveChannels, _, err := client.GetTopInactiveChannelsForUserSince(teamId, model.TimeRangeToday, 0, 5) + topInactiveChannels, _, err := client.GetTopInactiveChannelsForUserSince(teamId, model.TimeRangeToday, 0, 3) require.NoError(t, err) for i, channel := range topInactiveChannels.Items { diff --git a/app/channel_test.go b/app/channel_test.go index c4525ae706..93ce63dfa9 100644 --- a/app/channel_test.go +++ b/app/channel_test.go @@ -2685,13 +2685,30 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - channel2 := th.CreateChannel(th.Context, th.BasicTeam) + channel2 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel3 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel5 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel6 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + th.AddUserToChannel(th.BasicUser, channel2) + th.AddUserToChannel(th.BasicUser, channel3) + th.AddUserToChannel(th.BasicUser, channel4) + th.AddUserToChannel(th.BasicUser, channel5) + th.AddUserToChannel(th.BasicUser, channel6) - // delete offtopic channel - which interferes with 'least' active channel results + // delete offtopic, town square, basicChannel channel - which interferes with 'least' active channel results offTopicChannel, appErr := th.App.GetChannelByName(th.Context, "off-topic", th.BasicTeam.Id, false) require.Nil(t, appErr, "Expected nil, didn't receive nil") appErr = th.App.PermanentDeleteChannel(th.Context, offTopicChannel) require.Nil(t, appErr) + townSquareChannel, appErr := th.App.GetChannelByName(th.Context, "town-square", th.BasicTeam.Id, false) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, townSquareChannel) + require.Nil(t, appErr) + basicChannel, appErr := th.App.GetChannel(th.Context, th.BasicChannel.Id) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, basicChannel) + require.Nil(t, appErr) // add a bot post to ensure it's counted _, err := th.Server.Store.Post().Save(&model.Post{ @@ -2704,8 +2721,6 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { }) require.NoError(t, err) - channel3 := th.CreatePrivateChannel(th.Context, th.BasicTeam) - // add a webhook post to ensure it's counted _, err = th.Server.Store.Post().Save(&model.Post{ Message: "hello from a webhook", @@ -2717,16 +2732,7 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { }) require.NoError(t, err) - channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam) - channel5 := th.CreateChannel(th.Context, th.BasicTeam) - channel6 := th.CreatePrivateChannel(th.Context, th.BasicTeam) - th.AddUserToChannel(th.BasicUser, channel2) - th.AddUserToChannel(th.BasicUser, channel3) - th.AddUserToChannel(th.BasicUser, channel4) - th.AddUserToChannel(th.BasicUser, channel5) - th.AddUserToChannel(th.BasicUser, channel6) - - channels := [6]*model.Channel{th.BasicChannel, channel2, channel3, channel4, channel5, channel6} + channels := [5]*model.Channel{channel2, channel3, channel4, channel5, channel6} i := len(channels) for _, channel := range channels { @@ -2745,13 +2751,12 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { {ID: channel4.Id, MessageCount: 3}, {ID: channel3.Id, MessageCount: 5}, {ID: channel2.Id, MessageCount: 6}, - {ID: th.BasicChannel.Id, MessageCount: 7}, } timeRange := model.StartOfDayForTimeRange(model.TimeRangeToday, time.Now().Location()) t.Run("get-top-channels-for-team-since", func(t *testing.T) { - topChannels, err := th.App.GetTopInactiveChannelsForTeamSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 6}) + topChannels, err := th.App.GetTopInactiveChannelsForTeamSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 5}) require.Nil(t, err) for i, channel := range topChannels.Items { @@ -2759,10 +2764,16 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) { assert.Equal(t, expectedTopChannels[i].MessageCount, channel.MessageCount) } - topChannels, err = th.App.GetTopInactiveChannelsForTeamSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 1, PerPage: 5}) + topChannels, err = th.App.GetTopInactiveChannelsForTeamSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 1, PerPage: 4}) require.Nil(t, err) - assert.Equal(t, th.BasicChannel.Id, topChannels.Items[0].ID) - assert.Equal(t, int64(7), topChannels.Items[0].MessageCount) + assert.Equal(t, channel2.Id, topChannels.Items[0].ID) + assert.Equal(t, int64(6), topChannels.Items[0].MessageCount) + + // it simulates channel being created recently + _ = th.CreatePrivateChannel(th.Context, th.BasicTeam) + topChannels, err = th.App.GetTopInactiveChannelsForTeamSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 6}) + require.Nil(t, err) + assert.Equal(t, 5, len(topChannels.Items)) }) } @@ -2770,13 +2781,21 @@ func TestGetTopInactiveChannelsForUserSince(t *testing.T) { th := Setup(t).InitBasic() defer th.TearDown() - // delete offtopic channel - which interferes with 'least' active channel results + // delete offtopic, town-square, th.basicchannel channels - which interferes with 'least' active channel results offTopicChannel, appErr := th.App.GetChannelByName(th.Context, "off-topic", th.BasicTeam.Id, false) require.Nil(t, appErr, "Expected nil, didn't receive nil") appErr = th.App.PermanentDeleteChannel(th.Context, offTopicChannel) require.Nil(t, appErr) + townSquareChannel, appErr := th.App.GetChannelByName(th.Context, "town-square", th.BasicTeam.Id, false) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, townSquareChannel) + require.Nil(t, appErr) + basicChannel, appErr := th.App.GetChannel(th.Context, th.BasicChannel.Id) + require.Nil(t, appErr, "Expected nil, didn't receive nil") + appErr = th.App.PermanentDeleteChannel(th.Context, basicChannel) + require.Nil(t, appErr) - channel2 := th.CreateChannel(th.Context, th.BasicTeam) + channel2 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) // add a bot post to ensure it's counted _, err := th.Server.Store.Post().Save(&model.Post{ @@ -2789,7 +2808,7 @@ func TestGetTopInactiveChannelsForUserSince(t *testing.T) { }) require.NoError(t, err) - channel3 := th.CreatePrivateChannel(th.Context, th.BasicTeam) + channel3 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) // add a webhook post to ensure it's counted _, err = th.Server.Store.Post().Save(&model.Post{ @@ -2802,16 +2821,16 @@ func TestGetTopInactiveChannelsForUserSince(t *testing.T) { }) require.NoError(t, err) - channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam) - channel5 := th.CreateChannel(th.Context, th.BasicTeam) - channel6 := th.CreatePrivateChannel(th.Context, th.BasicTeam) + channel4 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel5 := th.CreateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) + channel6 := th.CreatePrivateChannel(th.Context, th.BasicTeam, WithCreateAt(1)) th.AddUserToChannel(th.BasicUser, channel2) th.AddUserToChannel(th.BasicUser, channel3) th.AddUserToChannel(th.BasicUser, channel4) th.AddUserToChannel(th.BasicUser, channel5) th.AddUserToChannel(th.BasicUser, channel6) - channels := [6]*model.Channel{th.BasicChannel, channel2, channel3, channel4, channel5, channel6} + channels := [5]*model.Channel{channel2, channel3, channel4, channel5, channel6} i := len(channels) for _, channel := range channels { @@ -2830,24 +2849,23 @@ func TestGetTopInactiveChannelsForUserSince(t *testing.T) { {ID: channel4.Id, MessageCount: 3}, {ID: channel3.Id, MessageCount: 5}, {ID: channel2.Id, MessageCount: 6}, - {ID: th.BasicChannel.Id, MessageCount: 7}, } timeRange := model.StartOfDayForTimeRange(model.TimeRangeToday, time.Now().Location()) t.Run("get-top-channels-for-user-since", func(t *testing.T) { - topChannels, err := th.App.GetTopInactiveChannelsForUserSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 5}) + topChannels, err := th.App.GetTopInactiveChannelsForUserSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 0, PerPage: 4}) require.Nil(t, err) - require.Equal(t, len(topChannels.Items), 5) + require.Equal(t, len(topChannels.Items), 4) for i, channel := range topChannels.Items { assert.Equal(t, expectedTopChannels[i].ID, channel.ID) assert.Equal(t, expectedTopChannels[i].MessageCount, channel.MessageCount) } - topChannels, err = th.App.GetTopInactiveChannelsForUserSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 1, PerPage: 5}) + topChannels, err = th.App.GetTopInactiveChannelsForUserSince(th.Context, th.BasicChannel.TeamId, th.BasicUser.Id, &model.InsightsOpts{StartUnixMilli: timeRange.UnixMilli(), Page: 1, PerPage: 4}) require.Nil(t, err) require.Equal(t, len(topChannels.Items), 1) - assert.Equal(t, th.BasicChannel.Id, topChannels.Items[0].ID) - assert.Equal(t, int64(7), topChannels.Items[0].MessageCount) + assert.Equal(t, channel2.Id, topChannels.Items[0].ID) + assert.Equal(t, int64(6), topChannels.Items[0].MessageCount) }) } diff --git a/app/helper_test.go b/app/helper_test.go index 5b15d3f519..7de517ea58 100644 --- a/app/helper_test.go +++ b/app/helper_test.go @@ -327,12 +327,18 @@ func WithShared(v bool) ChannelOption { } } +func WithCreateAt(v int64) ChannelOption { + return func(channel *model.Channel) { + channel.CreateAt = *model.NewInt64(v) + } +} + func (th *TestHelper) CreateChannel(c request.CTX, team *model.Team, options ...ChannelOption) *model.Channel { return th.createChannel(c, team, model.ChannelTypeOpen, options...) } -func (th *TestHelper) CreatePrivateChannel(c request.CTX, team *model.Team) *model.Channel { - return th.createChannel(c, team, model.ChannelTypePrivate) +func (th *TestHelper) CreatePrivateChannel(c request.CTX, team *model.Team, options ...ChannelOption) *model.Channel { + return th.createChannel(c, team, model.ChannelTypePrivate, options...) } func (th *TestHelper) createChannel(c request.CTX, team *model.Team, channelType model.ChannelType, options ...ChannelOption) *model.Channel { diff --git a/model/channel.go b/model/channel.go index e66c30faef..e900011cc9 100644 --- a/model/channel.go +++ b/model/channel.go @@ -296,8 +296,9 @@ func (o *Channel) PreSave() { o.Name = SanitizeUnicode(o.Name) o.DisplayName = SanitizeUnicode(o.DisplayName) - - o.CreateAt = GetMillis() + if o.CreateAt == 0 { + o.CreateAt = GetMillis() + } o.UpdateAt = o.CreateAt o.ExtraUpdateAt = 0 } diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index e772f2706d..19686d967d 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -4337,48 +4337,45 @@ func (s SqlChannelStore) GetTopInactiveChannelsForTeamSince(teamID string, userI LastActivityAt FROM ((SELECT - Posts.ChannelId AS ID, + PublicChannels.Id AS ID, 'O' AS Type, PublicChannels.DisplayName AS DisplayName, PublicChannels.Name AS Name, - count(Posts.Id) AS MessageCount, - max(Posts.CreateAt) AS LastActivityAt + COALESCE(count(Posts.Id), 0) AS MessageCount, + COALESCE(max(Posts.CreateAt), 0) AS LastActivityAt FROM - Posts - LEFT JOIN PublicChannels on Posts.ChannelId = PublicChannels.Id + PublicChannels + LEFT JOIN Posts on Posts.ChannelId = PublicChannels.Id AND Posts.Type = '' AND Posts.CreateAt > ? AND Posts.DeleteAt = 0 + LEFT JOIN Channels on Channels.Id = PublicChannels.Id WHERE - Posts.DeleteAt = 0 - AND Posts.CreateAt > ? - AND (Posts.Type = '' OR Posts.Type = 'system_join_channel') - AND PublicChannels.TeamId = ? + PublicChannels.TeamId = ? AND PublicChannels.DeleteAt = 0 + AND Channels.CreateAt < ? GROUP BY - Posts.ChannelId, + PublicChannels.Id, PublicChannels.DisplayName, PublicChannels.Name, PublicChannels.TeamId) UNION ALL (SELECT - Posts.ChannelId AS ID, + Channels.Id AS ID, Channels.Type AS Type, Channels.DisplayName AS DisplayName, Channels.Name AS Name, - count(Posts.Id) AS MessageCount, - max(Posts.CreateAt) AS LastActivityAt + COALESCE(count(Posts.Id), 0) AS MessageCount, + COALESCE(max(Posts.CreateAt), 0) AS LastActivityAt FROM - Posts - LEFT JOIN Channels on Posts.ChannelId = Channels.Id + 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 WHERE - Posts.DeleteAt = 0 - AND Posts.CreateAt > ? - AND (Posts.Type = '' OR Posts.Type = 'system_join_channel') - AND Channels.TeamId = ? + Channels.TeamId = ? + AND Channels.CreateAt < ? AND Channels.Type = 'P' AND Channels.DeleteAt = 0 AND ChannelMembers.UserId = ? GROUP BY - Posts.ChannelId, + Channels.Id, Channels.Type, Channels.DisplayName, Channels.Name)) AS A @@ -4387,8 +4384,7 @@ func (s SqlChannelStore) GetTopInactiveChannelsForTeamSince(teamID string, userI Name ASC LIMIT ? OFFSET ?` - args = append(args, since, teamID, since, teamID, userID, limit+1, offset) - + args = append(args, since, teamID, since, since, teamID, since, userID, limit+1, offset) if err := s.GetReplicaX().Select(&channels, query, args...); err != nil { return nil, errors.Wrap(err, "failed to get top Channels") } @@ -4411,25 +4407,23 @@ func (s SqlChannelStore) GetTopInactiveChannelsForUserSince(teamID string, userI query = ` SELECT - Posts.ChannelId AS ID, + Channels.Id AS ID, Channels.Type AS Type, Channels.DisplayName AS DisplayName, Channels.Name AS Name, - count(Posts.Id) AS MessageCount, - max(Posts.CreateAt) AS LastActivityAt + COALESCE(count(Posts.Id), 0) AS MessageCount, + COALESCE(max(Posts.CreateAt), 0) AS LastActivityAt FROM - Posts - LEFT JOIN Channels on Posts.ChannelId = Channels.Id + 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 WHERE - Posts.DeleteAt = 0 - AND Posts.CreateAt > ? - AND (Posts.Type = '' OR Posts.Type = 'system_join_channel') - AND Channels.DeleteAt = 0 + Channels.DeleteAt = 0 + AND Channels.CreateAt < ? AND (Channels.Type = 'O' OR Channels.Type = 'P') AND ChannelMembers.UserId = ? ` - args = []any{since, userID} + args = []any{since, since, userID} if teamID != "" { query += ` @@ -4439,7 +4433,7 @@ func (s SqlChannelStore) GetTopInactiveChannelsForUserSince(teamID string, userI query += ` Group By - Posts.ChannelId, + Channels.Id, Channels.Type, Channels.DisplayName, Channels.Name diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 913ac7e08a..7b2757ad14 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -7978,6 +7978,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { DisplayName: "test_share_flag asdf", Name: "test_share_flag_public0", Type: model.ChannelTypeOpen, + CreateAt: 1, } channelSaved0, err := ss.Channel().Save(channelPublic0, 999) @@ -7989,6 +7990,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { DisplayName: "test_share_flag", Name: "test_share_flag", Type: model.ChannelTypeOpen, + CreateAt: 1, } channelSaved1, err := ss.Channel().Save(channelPublic1, 999) @@ -8001,6 +8003,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { c3.DisplayName = "Channel3" + model.NewId() c3.Name = NewTestId() c3.Type = model.ChannelTypePrivate + c3.CreateAt = 1 channelPrivate, nErr := ss.Channel().Save(&c3, -1) require.NoError(t, nErr) @@ -8080,7 +8083,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { // for u1 t.Run("top inactive channels for team - u1 ", func(t *testing.T) { - topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForTeamSince(team.Id, u1.Id, 0, 0, 10) + 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) @@ -8096,7 +8099,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { }) t.Run("top inactive channels for user - u1 ", func(t *testing.T) { - topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForUserSince(team.Id, u1.Id, 0, 0, 10) + 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) @@ -8105,7 +8108,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { // for u2 t.Run("top inactive channels for team - u2 ", func(t *testing.T) { - topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForTeamSince(team.Id, u2.Id, 0, 0, 10) + topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForTeamSince(team.Id, u2.Id, 2, 0, 10) require.NoError(t, err) require.Len(t, topInactiveChannels.Items, 2) require.Equal(t, topInactiveChannels.Items[0].ID, channelSaved0.Id) @@ -8114,7 +8117,7 @@ func testGetTopInactiveChannels(t *testing.T, ss store.Store) { }) t.Run("top inactive channels for user - u2 ", func(t *testing.T) { - topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForUserSince(team.Id, u2.Id, 0, 0, 10) + topInactiveChannels, err := ss.Channel().GetTopInactiveChannelsForUserSince(team.Id, u2.Id, 2, 0, 10) require.NoError(t, err) require.Len(t, topInactiveChannels.Items, 1) require.Equal(t, topInactiveChannels.Items[0].ID, channelPublic0.Id)