Fix bot things 2

This commit is contained in:
2025-02-11 02:06:35 +07:00
parent 898ff85eed
commit d7731dda0e
10 changed files with 164 additions and 121 deletions

View File

@@ -51,16 +51,19 @@ public class DataController : ControllerBase
/// <summary>
/// Retrieves tickers for a given account and timeframe, utilizing caching to improve performance.
/// </summary>
/// <param name="accountName">The name of the account to retrieve tickers for.</param>
/// <param name="timeframe">The timeframe for which to retrieve tickers.</param>
/// <returns>An array of tickers.</returns>
[HttpPost("GetTickers")]
public async Task<ActionResult<Ticker[]>> GetTickers(string accountName, Timeframe timeframe)
public async Task<ActionResult<Ticker[]>> GetTickers(Timeframe timeframe)
{
var account = await _accountService.GetAccount(accountName, true, false);
var cacheKey = string.Concat(accountName, timeframe.ToString());
var tickers = _cacheService.GetOrSave(cacheKey,
() => { return _exchangeService.GetTickers(account, timeframe).Result; }, TimeSpan.FromHours(2));
var cacheKey = string.Concat(timeframe.ToString());
var tickers = _cacheService.GetValue<List<Ticker>>(cacheKey);
if (tickers == null)
{
tickers = await _exchangeService.GetTickers(timeframe);
_cacheService.SaveValue(cacheKey, tickers, TimeSpan.FromHours(2));
}
return Ok(tickers);
}