Fix json serialization + preloaded candle
This commit is contained in:
@@ -568,26 +568,12 @@ public class DataController : ControllerBase
|
||||
/// <param name="endDate">Optional end date for the balance history (defaults to current time)</param>
|
||||
/// <returns>A list of agent balances within the specified date range</returns>
|
||||
[HttpGet("GetAgentBalances")]
|
||||
public async Task<ActionResult<IList<AgentBalance>>> GetAgentBalances(
|
||||
public async Task<ActionResult<AgentBalanceHistory>> GetAgentBalances(
|
||||
string agentName,
|
||||
DateTime startDate,
|
||||
DateTime? endDate = null)
|
||||
{
|
||||
string cacheKey = $"AgentBalances_{agentName}_{startDate:yyyyMMdd}_{endDate?.ToString("yyyyMMdd") ?? "now"}";
|
||||
|
||||
// Check if the balances are already cached
|
||||
var cachedBalances = _cacheService.GetValue<IList<AgentBalance>>(cacheKey);
|
||||
|
||||
if (cachedBalances != null)
|
||||
{
|
||||
return Ok(cachedBalances);
|
||||
}
|
||||
|
||||
var balances = await _statisticService.GetAgentBalances(agentName, startDate, endDate);
|
||||
|
||||
// Cache the results for 5 minutes
|
||||
_cacheService.SaveValue(cacheKey, balances, TimeSpan.FromMinutes(5));
|
||||
|
||||
return Ok(balances);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user