Fix counting of posts, remove redundant limit offset for queries
Этот коммит содержится в:
@@ -2983,9 +2983,7 @@ func (s *SqlPostStore) GetTopDMsForUserSince(userID string, since int64, offset
|
||||
Join("Posts as p on p.ChannelId = vch.Id").
|
||||
Where(sq.Gt{
|
||||
"p.UpdateAt": since,
|
||||
}).GroupBy("vch.id").
|
||||
Limit(uint64(limit)).
|
||||
Offset(uint64(offset))
|
||||
}).GroupBy("vch.id")
|
||||
|
||||
topDMsBuilder = topDMsBuilder.OrderBy("MessageCount DESC").Limit(uint64(limit)).Offset(uint64(offset))
|
||||
|
||||
@@ -3006,7 +3004,14 @@ func (s *SqlPostStore) GetTopDMsForUserSince(userID string, since int64, offset
|
||||
|
||||
func postProcessTopDMs(userID string, topDMs []*model.TopDM) []*model.TopDM {
|
||||
for _, topDM := range topDMs {
|
||||
// divide message count by 2, because it's counted twice due to channel memberships being 2 for dms.
|
||||
topDM.MessageCount = topDM.MessageCount / 2
|
||||
participants := strings.Split(topDM.Participants, ",")
|
||||
if len(participants) == 1 {
|
||||
// chatting to self
|
||||
topDM.SecondParticipant = userID
|
||||
continue
|
||||
}
|
||||
if participants[0] == userID {
|
||||
topDM.SecondParticipant = participants[1]
|
||||
} else {
|
||||
|
||||
Ссылка в новой задаче
Block a user