Fix agent count
This commit is contained in:
@@ -82,11 +82,11 @@ log "🚀 Starting safe migration for environment: $ENVIRONMENT"
|
|||||||
|
|
||||||
# Validate environment
|
# Validate environment
|
||||||
case $ENVIRONMENT in
|
case $ENVIRONMENT in
|
||||||
"Development"|"Sandbox"|"Production"|"Oda")
|
"Development"|"SandboxLocal"|"Production"|"Oda")
|
||||||
log "✅ Environment '$ENVIRONMENT' is valid"
|
log "✅ Environment '$ENVIRONMENT' is valid"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "❌ Invalid environment '$ENVIRONMENT'. Use: Development, Sandbox, Production, or Oda"
|
error "❌ Invalid environment '$ENVIRONMENT'. Use: Development, SandboxLocal, Production, or Oda"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public interface IPlatformSummaryGrain : IGrainWithStringKey
|
|||||||
/// Increments the total agent count when a new agent is activated
|
/// Increments the total agent count when a new agent is activated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[OneWay]
|
[OneWay]
|
||||||
Task IncrementAgentCountAsync();
|
Task RefreshAgentCountAsync();
|
||||||
|
|
||||||
[OneWay]
|
[OneWay]
|
||||||
Task OnPositionClosedAsync(PositionClosedEvent evt);
|
Task OnPositionClosedAsync(PositionClosedEvent evt);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class AgentGrain : Grain, IAgentGrain
|
|||||||
await ServiceScopeHelpers.WithScopedService<IGrainFactory>(_scopeFactory, async grainFactory =>
|
await ServiceScopeHelpers.WithScopedService<IGrainFactory>(_scopeFactory, async grainFactory =>
|
||||||
{
|
{
|
||||||
var platformGrain = grainFactory.GetGrain<IPlatformSummaryGrain>("platform-summary");
|
var platformGrain = grainFactory.GetGrain<IPlatformSummaryGrain>("platform-summary");
|
||||||
await platformGrain.IncrementAgentCountAsync();
|
await platformGrain.RefreshAgentCountAsync();
|
||||||
_logger.LogDebug("Notified platform summary about new agent activation for user {UserId}", userId);
|
_logger.LogDebug("Notified platform summary about new agent activation for user {UserId}", userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
|||||||
_logger.LogInformation("Created initial empty daily snapshot for {Date}", today);
|
_logger.LogInformation("Created initial empty daily snapshot for {Date}", today);
|
||||||
}
|
}
|
||||||
|
|
||||||
_state.State.TotalAgents = await _agentService.GetTotalAgentCount();
|
|
||||||
|
|
||||||
await RefreshDataAsync();
|
await RefreshDataAsync();
|
||||||
}
|
}
|
||||||
@@ -219,16 +218,12 @@ public class PlatformSummaryGrain : Grain, IPlatformSummaryGrain, IRemindable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task IncrementAgentCountAsync()
|
public async Task RefreshAgentCountAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Incrementing agent count from {CurrentCount} to {NewCount}",
|
_state.State.TotalAgents = await _agentService.GetTotalAgentCount();
|
||||||
_state.State.TotalAgents, _state.State.TotalAgents + 1);
|
|
||||||
|
|
||||||
_state.State.TotalAgents++;
|
|
||||||
await _state.WriteStateAsync();
|
await _state.WriteStateAsync();
|
||||||
|
|
||||||
_logger.LogInformation("Agent count incremented to: {NewCount}", _state.State.TotalAgents);
|
_logger.LogInformation("Agent count incremented to: {NewCount}", _state.State.TotalAgents);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -116,8 +116,6 @@ public class UserService : IUserService
|
|||||||
var agentGrain = _grainFactory.GetGrain<IAgentGrain>(user.Id);
|
var agentGrain = _grainFactory.GetGrain<IAgentGrain>(user.Id);
|
||||||
await agentGrain.InitializeAsync(user.Id, string.Empty);
|
await agentGrain.InitializeAsync(user.Id, string.Empty);
|
||||||
_logger.LogInformation("AgentGrain initialized for new user {UserId}", user.Id);
|
_logger.LogInformation("AgentGrain initialized for new user {UserId}", user.Id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user