Fix update agent save + revert market in redis
This commit is contained in:
@@ -161,6 +161,21 @@ public class AgentGrain : Grain, IAgentGrain
|
||||
}
|
||||
}
|
||||
|
||||
[OneWay]
|
||||
public async Task ForceUpdateSummary()
|
||||
{
|
||||
// Check if last update was more than 2 minutes ago
|
||||
if (_state.State.LastSummaryUpdateTime.HasValue &&
|
||||
DateTime.UtcNow - _state.State.LastSummaryUpdateTime.Value < TimeSpan.FromMinutes(2))
|
||||
{
|
||||
_logger.LogDebug("Skipping summary update for agent {UserId} - last update was {TimeAgo} ago",
|
||||
this.GetPrimaryKeyLong(), DateTime.UtcNow - _state.State.LastSummaryUpdateTime.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
await UpdateSummary();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the agent summary by recalculating from position data (used for initialization or manual refresh)
|
||||
/// </summary>
|
||||
@@ -274,6 +289,10 @@ public class AgentGrain : Grain, IAgentGrain
|
||||
// Save summary to database
|
||||
await _agentService.SaveOrUpdateAgentSummary(summary);
|
||||
|
||||
// Update last summary update time
|
||||
_state.State.LastSummaryUpdateTime = DateTime.UtcNow;
|
||||
await _state.WriteStateAsync();
|
||||
|
||||
// Insert balance tracking data
|
||||
InsertBalanceTrackingData(totalBalance, botsAllocationUsdValue, netPnL, usdcWalletValue,
|
||||
usdcInPositionsValue);
|
||||
|
||||
Reference in New Issue
Block a user