Add more data to rewind

This commit is contained in:
2025-12-26 01:08:10 +08:00
parent 4e9c5733d1
commit b193224a2c
4 changed files with 63 additions and 15 deletions

View File

@@ -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();
}
}