Этот коммит содержится в:
Shivashis Padhi
2022-07-28 12:46:18 +05:30
родитель 55bf7458d7
Коммит f007d94155
3 изменённых файлов: 7 добавлений и 12 удалений

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

@@ -909,8 +909,7 @@ func TestGetTopDMsForUserSince(t *testing.T) {
client = th.Client
topDMs, _, topDmsErr := client.GetTopDMsForUserSince("today", 0, 100)
require.NoError(t, topDmsErr)
require.Len(t, topDMs.Items, 2)
require.Equal(t, topDMs.Items[1].MessageCount, int64(2))
require.Len(t, topDMs.Items, 1)
require.Equal(t, topDMs.Items[0].MessageCount, int64(3))
require.Equal(t, topDMs.Items[0].SecondParticipant.Id, basicUser1.Id)
})
@@ -921,8 +920,8 @@ func TestGetTopDMsForUserSince(t *testing.T) {
client = th.Client
topDMs, _, topDmsErr := client.GetTopDMsForUserSince("today", 0, 100)
require.NoError(t, topDmsErr)
require.Len(t, topDMs.Items, 2)
require.Equal(t, topDMs.Items[1].MessageCount, int64(1))
require.Len(t, topDMs.Items, 1)
require.Equal(t, topDMs.Items[0].MessageCount, int64(3))
})
// deactivate basicuser1
_, err = th.Client.DeleteUser(basicUser1.Id)
@@ -933,8 +932,7 @@ func TestGetTopDMsForUserSince(t *testing.T) {
client = th.Client
topDMs, _, topDmsErr := client.GetTopDMsForUserSince("today", 0, 100)
require.NoError(t, topDmsErr)
require.Len(t, topDMs.Items, 2)
require.Equal(t, topDMs.Items[1].MessageCount, int64(2))
require.Len(t, topDMs.Items, 1)
require.Equal(t, topDMs.Items[0].MessageCount, int64(3))
})
}

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

@@ -3017,7 +3017,7 @@ func postProcessTopDMs(s *SqlPostStore, userID string, topDMs []*model.TopDM) ([
var secondParticipantId string
if len(participants) == 1 {
// chatting to self
secondParticipantId = userID
continue
} else {
// divide message count by 2, because it's counted twice due to channel memberships being 2 for dms.
topDM.MessageCount = topDM.MessageCount / 2

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

@@ -4091,7 +4091,7 @@ func testGetTopDMsForUserSince(t *testing.T, ss store.Store, s SqlStore) {
require.Equal(t, topDMs.Items[0].SecondParticipant.Id, u3.Id)
require.Equal(t, topDMs.Items[0].MessageCount, int64(4))
})
t.Run("topDMs will consider self dms", func(t *testing.T) {
t.Run("topDMs will not consider self dms", func(t *testing.T) {
chUser, nErr := ss.Channel().CreateDirectChannel(&user, &user)
require.NoError(t, nErr)
_, err = ss.Post().Save(&model.Post{
@@ -4105,9 +4105,6 @@ func testGetTopDMsForUserSince(t *testing.T, ss store.Store, s SqlStore) {
topDMs, err := ss.Post().GetTopDMsForUserSince(user.Id, 100, 0, 100)
require.NoError(t, err)
// len of topDMs.Items should be 3
require.Len(t, topDMs.Items, 3)
// check order, magnitude of items
require.Equal(t, topDMs.Items[2].SecondParticipant.Id, user.Id)
require.Equal(t, topDMs.Items[2].MessageCount, int64(1))
require.Len(t, topDMs.Items, 2)
})
}