- Added IConfiguration dependency to BotController for accessing environment variables. - Updated GetBotsPaginatedAsync method in BotService and IBotService to include a flag for filtering profitable bots. - Modified DataController to utilize the new filtering option for agent summaries and bot retrieval. - Enhanced PostgreSqlBotRepository to apply filtering based on profitability when querying bots.
58 lines
2.7 KiB
C#
58 lines
2.7 KiB
C#
using Managing.Domain.Bots;
|
|
using static Managing.Common.Enums;
|
|
|
|
namespace Managing.Application.Abstractions.Repositories;
|
|
|
|
public interface IBotRepository
|
|
{
|
|
Task InsertBotAsync(Bot bot);
|
|
Task<IEnumerable<Bot>> GetBotsAsync();
|
|
Task UpdateBot(Bot bot);
|
|
Task DeleteBot(Guid identifier);
|
|
Task<Bot> GetBotByIdentifierAsync(Guid identifier);
|
|
Task<IEnumerable<Bot>> GetBotsByIdsAsync(IEnumerable<Guid> identifiers);
|
|
Task<IEnumerable<Bot>> GetBotsByUserIdAsync(int id);
|
|
Task<IEnumerable<Bot>> GetBotsByStatusAsync(BotStatus status);
|
|
Task<Bot> GetBotByNameAsync(string name);
|
|
Task<Bot> GetBotByUserIdAndNameAsync(int userId, string name);
|
|
|
|
/// <summary>
|
|
/// Gets paginated bots with filtering and sorting
|
|
/// </summary>
|
|
/// <param name="pageNumber">Page number (1-based)</param>
|
|
/// <param name="pageSize">Number of items per page</param>
|
|
/// <param name="status">Filter by status (optional)</param>
|
|
/// <param name="name">Filter by name (partial match, case-insensitive)</param>
|
|
/// <param name="ticker">Filter by ticker (partial match, case-insensitive)</param>
|
|
/// <param name="agentName">Filter by agent name (partial match, case-insensitive)</param>
|
|
/// <param name="sortBy">Sort field</param>
|
|
/// <param name="sortDirection">Sort direction ("Asc" or "Desc")</param>
|
|
/// <param name="showOnlyProfitable">Whether to show only profitable bots (ROI > 0)</param>
|
|
/// <returns>Tuple containing the bots for the current page and total count</returns>
|
|
Task<(IEnumerable<Bot> Bots, int TotalCount)> GetBotsPaginatedAsync(
|
|
int pageNumber,
|
|
int pageSize,
|
|
BotStatus? status = null,
|
|
string? name = null,
|
|
string? ticker = null,
|
|
string? agentName = null,
|
|
BotSortableColumn sortBy = BotSortableColumn.CreateDate,
|
|
string sortDirection = "Desc",
|
|
bool showOnlyProfitable = false);
|
|
|
|
/// <summary>
|
|
/// Gets the top performing bots by PnL from the specified statuses
|
|
/// </summary>
|
|
/// <param name="statuses">Bot statuses to include in the query</param>
|
|
/// <param name="count">Number of top performers to return (default: 3)</param>
|
|
/// <returns>Top performing bots ordered by PnL descending</returns>
|
|
Task<IEnumerable<Bot>> GetTopBotsByPnLAsync(IEnumerable<BotStatus> statuses, int count = 3);
|
|
|
|
/// <summary>
|
|
/// Gets the top performing bots by ROI from the specified statuses
|
|
/// </summary>
|
|
/// <param name="statuses">Bot statuses to include in the query</param>
|
|
/// <param name="count">Number of top performers to return (default: 3)</param>
|
|
/// <returns>Top performing bots ordered by ROI descending</returns>
|
|
Task<IEnumerable<Bot>> GetTopBotsByRoiAsync(IEnumerable<BotStatus> statuses, int count = 3);
|
|
} |