Fix long time update AgentName
This commit is contained in:
@@ -51,8 +51,33 @@ public class AgentGrain : Grain, IAgentGrain
|
||||
{
|
||||
_state.State.AgentName = agentName;
|
||||
await _state.WriteStateAsync();
|
||||
await UpdateSummary();
|
||||
_logger.LogInformation("Agent {UserId} initialized with name {AgentName}", userId, agentName);
|
||||
|
||||
// Create an empty AgentSummary for the new agent
|
||||
var emptySummary = new AgentSummary
|
||||
{
|
||||
UserId = userId,
|
||||
AgentName = agentName,
|
||||
TotalPnL = 0,
|
||||
TotalROI = 0,
|
||||
Wins = 0,
|
||||
Losses = 0,
|
||||
Runtime = null,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
ActiveStrategiesCount = 0,
|
||||
TotalVolume = 0,
|
||||
TotalBalance = 0
|
||||
};
|
||||
|
||||
await _agentService.SaveOrUpdateAgentSummary(emptySummary);
|
||||
_logger.LogInformation("Agent {UserId} initialized with name {AgentName} and empty summary", userId, agentName);
|
||||
}
|
||||
|
||||
public async Task UpdateAgentNameAsync(string agentName)
|
||||
{
|
||||
_state.State.AgentName = agentName;
|
||||
await _state.WriteStateAsync();
|
||||
_logger.LogInformation("Agent {UserId} updated with name {AgentName}", this.GetPrimaryKeyLong(), agentName);
|
||||
}
|
||||
|
||||
public async Task OnAgentSummaryUpdateAsync(AgentSummaryUpdateEvent updateEvent)
|
||||
|
||||
Reference in New Issue
Block a user