Get TotalAgentCount
This commit is contained in:
@@ -35,4 +35,10 @@ public interface IAgentSummaryRepository
|
||||
/// <param name="userId">The user ID</param>
|
||||
/// <param name="agentName">The new agent name</param>
|
||||
Task UpdateAgentNameAsync(int userId, string agentName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total count of agents
|
||||
/// </summary>
|
||||
/// <returns>Total number of agents</returns>
|
||||
Task<int> GetTotalAgentCount();
|
||||
}
|
||||
@@ -21,4 +21,10 @@ public interface IAgentService
|
||||
/// <param name="userId">The user ID</param>
|
||||
/// <param name="agentName">The new agent name</param>
|
||||
Task UpdateAgentSummaryNameAsync(int userId, string agentName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total count of agents
|
||||
/// </summary>
|
||||
/// <returns>Total number of agents</returns>
|
||||
Task<int> GetTotalAgentCount();
|
||||
}
|
||||
@@ -145,4 +145,9 @@ public class AgentService : IAgentService
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> GetTotalAgentCount()
|
||||
{
|
||||
return await _agentSummaryRepository.GetTotalAgentCount();
|
||||
}
|
||||
}
|
||||
@@ -99,11 +99,9 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
||||
{
|
||||
_logger.LogInformation("Refreshing platform summary data");
|
||||
|
||||
var agents = await _agentService.GetAllAgentSummaries();
|
||||
var strategies = await _botService.GetBotsAsync();
|
||||
|
||||
// Calculate totals
|
||||
var totalAgents = agents.Count();
|
||||
var totalActiveStrategies = strategies.Count(s => s.Status == BotStatus.Running);
|
||||
|
||||
// Calculate volume from strategies
|
||||
@@ -116,7 +114,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
||||
var (totalOpenInterest, totalPositionCount) = await CalculatePositionMetricsAsync();
|
||||
|
||||
// Update state
|
||||
_state.State.TotalAgents = totalAgents;
|
||||
_state.State.TotalActiveStrategies = totalActiveStrategies;
|
||||
|
||||
// Only update volume if it hasn't been updated by events recently
|
||||
@@ -131,6 +128,7 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
||||
_logger.LogDebug("Preserving event-updated volume: {Volume}", _state.State.TotalPlatformVolume);
|
||||
}
|
||||
|
||||
_state.State.TotalAgents = await _agentService.GetTotalAgentCount();
|
||||
_state.State.TotalPlatformPnL = totalPnL;
|
||||
_state.State.OpenInterest = totalOpenInterest;
|
||||
_state.State.TotalLifetimePositionCount = totalPositionCount;
|
||||
|
||||
@@ -318,4 +318,9 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
userId, agentName);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> GetTotalAgentCount()
|
||||
{
|
||||
return await _context.AgentSummaries.CountAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user