Add agent fees
This commit is contained in:
@@ -8,14 +8,8 @@ namespace Managing.Application.ManageBot.Commands
|
||||
/// </summary>
|
||||
public class GetAllAgentSummariesCommand : IRequest<IEnumerable<AgentSummary>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional time filter to apply (24H, 3D, 1W, 1M, 1Y, Total)
|
||||
/// </summary>
|
||||
public string TimeFilter { get; }
|
||||
|
||||
public GetAllAgentSummariesCommand(string timeFilter = "Total")
|
||||
public GetAllAgentSummariesCommand()
|
||||
{
|
||||
TimeFilter = timeFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,8 @@ namespace Managing.Application.ManageBot.Commands
|
||||
/// </summary>
|
||||
public class GetAllAgentsCommand : IRequest<Dictionary<User, List<Bot>>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional time filter to apply (24H, 3D, 1W, 1M, 1Y, Total)
|
||||
/// </summary>
|
||||
public string TimeFilter { get; }
|
||||
|
||||
public GetAllAgentsCommand(string timeFilter = "Total")
|
||||
public GetAllAgentsCommand()
|
||||
{
|
||||
TimeFilter = timeFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,31 +24,8 @@ namespace Managing.Application.ManageBot
|
||||
// Get all agent summaries from the database
|
||||
var allAgentSummaries = await _agentService.GetAllAgentSummaries();
|
||||
|
||||
if (request.TimeFilter != "Total")
|
||||
{
|
||||
var cutoffDate = GetCutoffDate(request.TimeFilter);
|
||||
allAgentSummaries = allAgentSummaries.Where(a =>
|
||||
a.UpdatedAt >= cutoffDate ||
|
||||
(a.Runtime.HasValue && a.Runtime.Value >= cutoffDate));
|
||||
}
|
||||
|
||||
return allAgentSummaries;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cutoff date based on the time filter
|
||||
/// </summary>
|
||||
private DateTime GetCutoffDate(string timeFilter)
|
||||
{
|
||||
return timeFilter switch
|
||||
{
|
||||
"24H" => DateTime.UtcNow.AddHours(-24),
|
||||
"3D" => DateTime.UtcNow.AddDays(-3),
|
||||
"1W" => DateTime.UtcNow.AddDays(-7),
|
||||
"1M" => DateTime.UtcNow.AddMonths(-1),
|
||||
"1Y" => DateTime.UtcNow.AddYears(-1),
|
||||
_ => DateTime.MinValue // Default to include all data
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,35 +35,11 @@ namespace Managing.Application.ManageBot
|
||||
var userBots = await _botService.GetBotsByUser(user.Id);
|
||||
var botList = userBots.ToList();
|
||||
|
||||
// Apply time filter if specified
|
||||
if (request.TimeFilter != "Total")
|
||||
{
|
||||
var cutoffDate = GetCutoffDate(request.TimeFilter);
|
||||
botList = botList.Where(bot =>
|
||||
bot.StartupTime >= cutoffDate ||
|
||||
bot.CreateDate >= cutoffDate).ToList();
|
||||
}
|
||||
|
||||
result[user] = botList;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cutoff date based on the time filter
|
||||
/// </summary>
|
||||
private DateTime GetCutoffDate(string timeFilter)
|
||||
{
|
||||
return timeFilter switch
|
||||
{
|
||||
"24H" => DateTime.UtcNow.AddHours(-24),
|
||||
"3D" => DateTime.UtcNow.AddDays(-3),
|
||||
"1W" => DateTime.UtcNow.AddDays(-7),
|
||||
"1M" => DateTime.UtcNow.AddMonths(-1),
|
||||
"1Y" => DateTime.UtcNow.AddYears(-1),
|
||||
_ => DateTime.MinValue // Default to include all data
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user