Update status to match UI

This commit is contained in:
2025-08-14 18:08:31 +07:00
parent e4049045c3
commit 6a2e4e81b1
18 changed files with 111 additions and 62 deletions

View File

@@ -52,12 +52,12 @@ namespace Managing.Application.ManageBot
{
var grain = _grainFactory.GetGrain<ILiveTradingBotGrain>(identifier);
await grain.StopAsync();
return BotStatus.Down;
return BotStatus.Stopped;
}
catch (Exception e)
{
_tradingBotLogger.LogError(e, "Error stopping bot {Identifier}", identifier);
return BotStatus.Down;
return BotStatus.Stopped;
}
}
@@ -97,13 +97,13 @@ namespace Managing.Application.ManageBot
var previousStatus = await registryGrain.GetBotStatus(identifier);
// If bot is already up, return the status directly
if (previousStatus == BotStatus.Up)
if (previousStatus == BotStatus.Running)
{
return BotStatus.Up;
return BotStatus.Running;
}
var botGrain = _grainFactory.GetGrain<ILiveTradingBotGrain>(identifier);
if (previousStatus == BotStatus.None)
if (previousStatus == BotStatus.Saved)
{
// First time startup
await botGrain.StartAsync();
@@ -134,12 +134,12 @@ namespace Managing.Application.ManageBot
await _messengerService.SendTradeMessage(restartMessage, false, account.User);
}
return BotStatus.Up;
return BotStatus.Running;
}
catch (Exception e)
{
_tradingBotLogger.LogError(e, "Error restarting bot {Identifier}", identifier);
return BotStatus.Down;
return BotStatus.Stopped;
}
}
@@ -190,7 +190,7 @@ namespace Managing.Application.ManageBot
public async Task<IEnumerable<string>> GetActiveBotsNamesAsync()
{
var bots = await _botRepository.GetBotsByStatusAsync(BotStatus.Up);
var bots = await _botRepository.GetBotsByStatusAsync(BotStatus.Running);
return bots.Select(b => b.Name);
}

View File

@@ -24,7 +24,7 @@ namespace Managing.Application.ManageBot
CancellationToken cancellationToken)
{
var result = new List<AgentStatusResponse>();
var allActiveBots = await _botService.GetBotsByStatusAsync(BotStatus.Up);
var allActiveBots = await _botService.GetBotsByStatusAsync(BotStatus.Running);
// Group bots by user and determine status
var agentGroups = allActiveBots
@@ -38,7 +38,7 @@ namespace Managing.Application.ManageBot
var bots = agentGroup.ToList();
// Determine agent status: Online if at least one strategy is running, Offline otherwise
var agentStatus = bots.Any(bot => bot.Status == BotStatus.Up)
var agentStatus = bots.Any(bot => bot.Status == BotStatus.Running)
? AgentStatus.Online
: AgentStatus.Offline;

View File

@@ -71,7 +71,7 @@ namespace Managing.Application.ManageBot
throw new Exception($"Failed to start bot: {ex.Message}, {ex.StackTrace}");
}
return request.CreateOnly ? BotStatus.None : BotStatus.Up;
return request.CreateOnly ? BotStatus.Saved : BotStatus.Running;
}
}
}

View File

@@ -25,7 +25,7 @@ namespace Managing.Application.ManageBot
var userBots = await _botService.GetBotsByUser(request.User.Id);
// Filter only active bots (status Up)
var activeBots = userBots.Where(bot => bot.Status == BotStatus.Up).ToList();
var activeBots = userBots.Where(bot => bot.Status == BotStatus.Running).ToList();
if (!activeBots.Any())
{