🐛 Fix sphere rewind
This commit is contained in:
@@ -103,12 +103,16 @@ public class SphereRewindServiceGrpc(
|
|||||||
.AsQueryable();
|
.AsQueryable();
|
||||||
|
|
||||||
var now = SystemClock.Instance.GetCurrentInstant();
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
var mostCalledRoom = await callQuery
|
var callDurations = await callQuery
|
||||||
.Where(c => c.Room.Type == Shared.Models.ChatRoomType.Group)
|
.Where(c => c.Room.Type == Shared.Models.ChatRoomType.Group)
|
||||||
|
.Select(c => new { RoomId = c.RoomId, Duration = c.CreatedAt.Minus(c.EndedAt ?? now).Seconds })
|
||||||
|
.ToListAsync();
|
||||||
|
var mostCalledRoomId = callDurations
|
||||||
.GroupBy(c => c.RoomId)
|
.GroupBy(c => c.RoomId)
|
||||||
.OrderByDescending(g => g.Sum(c => c.CreatedAt.Minus(c.EndedAt ?? now).Seconds))
|
.OrderByDescending(g => g.Sum(c => c.Duration))
|
||||||
.Select(g => g.First().Room)
|
.Select(g => g.Key)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefault();
|
||||||
|
var mostCalledRoom = mostCalledRoomId != Guid.Empty ? await db.ChatRooms.FindAsync(mostCalledRoomId) : null;
|
||||||
|
|
||||||
List<SnAccount>? mostCalledChatTopMembers = null;
|
List<SnAccount>? mostCalledChatTopMembers = null;
|
||||||
if (mostCalledRoom != null)
|
if (mostCalledRoom != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user