✨ Add more data to rewind
This commit is contained in:
@@ -208,7 +208,7 @@ public class ChatRoomService(
|
||||
{
|
||||
var group = $"chatroom:subscribers:{roomId}";
|
||||
var keys = (await cache.GetGroupKeysAsync(group)).ToList();
|
||||
|
||||
|
||||
var memberIds = new List<Guid>(keys.Count);
|
||||
foreach (var key in keys)
|
||||
{
|
||||
@@ -218,7 +218,22 @@ public class ChatRoomService(
|
||||
memberIds.Add(memberId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return memberIds;
|
||||
}
|
||||
|
||||
public async Task<List<SnAccount>> GetTopActiveMembers(Guid roomId, Instant startDate, Instant endDate)
|
||||
{
|
||||
var topMembers = await db.ChatMessages
|
||||
.Where(m => m.ChatRoomId == roomId && m.CreatedAt >= startDate && m.CreatedAt < endDate)
|
||||
.GroupBy(m => m.SenderId)
|
||||
.Select(g => new { SenderId = g.Key, MessageCount = g.Count() })
|
||||
.OrderByDescending(g => g.MessageCount)
|
||||
.Take(3)
|
||||
.ToListAsync();
|
||||
|
||||
var accountIds = topMembers.Select(t => t.SenderId).ToList();
|
||||
var accounts = await remoteAccounts.GetAccountBatch(accountIds);
|
||||
return accounts.Select(SnAccount.FromProtoValue).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user