Select total message count from Channel instead of counting posts
Этот коммит содержится в:
@@ -2978,7 +2978,7 @@ func (s *SqlPostStore) GetTopDMsForUserSince(userID string, since int64, offset
|
||||
aggregator = "string_agg(distinct cm.UserId, ',') as Participants"
|
||||
}
|
||||
|
||||
topDMsBuilder := s.getQueryBuilder().Select("count(p.id) as MessageCount", aggregator, "vch.Id as ChannelId").FromSelect(channelSelector, "vch").
|
||||
topDMsBuilder := s.getQueryBuilder().Select("vch.TotalMsgCount as MessageCount", aggregator, "vch.Id as ChannelId").FromSelect(channelSelector, "vch").
|
||||
Join("ChannelMembers as cm on cm.ChannelId = vch.Id").
|
||||
Join("Posts as p on p.ChannelId = vch.Id").
|
||||
Where(sq.And{
|
||||
@@ -3023,9 +3023,6 @@ func postProcessTopDMs(s *SqlPostStore, userID string, topDMs []*model.TopDM) ([
|
||||
// channel with self
|
||||
secondParticipantId = "-1"
|
||||
} else {
|
||||
// divide message count by 2, because it's counted twice due to channel memberships being 2 for dms.
|
||||
topDM.MessageCount = topDM.MessageCount / 2
|
||||
|
||||
if participants[0] == userID {
|
||||
secondParticipantId = participants[1]
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user