Return only online agent name
This commit is contained in:
@@ -903,29 +903,29 @@ public class DataController : ControllerBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an array of agent names and their statuses
|
||||
/// Retrieves an array of online agent names
|
||||
/// </summary>
|
||||
/// <returns>An array of agent status information</returns>
|
||||
/// <returns>An array of online agent names</returns>
|
||||
[HttpGet("GetAgentStatuses")]
|
||||
public async Task<ActionResult<List<AgentStatusResponse>>> GetAgentStatuses()
|
||||
public async Task<ActionResult<List<string>>> GetAgentStatuses()
|
||||
{
|
||||
const string cacheKey = "AgentStatuses";
|
||||
const string cacheKey = "OnlineAgentNames";
|
||||
|
||||
// Check if the agent statuses are already cached
|
||||
var cachedStatuses = _cacheService.GetValue<List<AgentStatusResponse>>(cacheKey);
|
||||
// Check if the online agent names are already cached
|
||||
var cachedAgentNames = _cacheService.GetValue<List<string>>(cacheKey);
|
||||
|
||||
if (cachedStatuses != null)
|
||||
if (cachedAgentNames != null)
|
||||
{
|
||||
return Ok(cachedStatuses);
|
||||
return Ok(cachedAgentNames);
|
||||
}
|
||||
|
||||
// Get all agent statuses
|
||||
var agentStatuses = await _mediator.Send(new GetAgentStatusesCommand());
|
||||
// Get only online agent names
|
||||
var onlineAgentNames = await _mediator.Send(new GetOnlineAgentNamesCommand());
|
||||
|
||||
// Cache the results for 2 minutes
|
||||
_cacheService.SaveValue(cacheKey, agentStatuses, TimeSpan.FromMinutes(2));
|
||||
_cacheService.SaveValue(cacheKey, onlineAgentNames, TimeSpan.FromMinutes(2));
|
||||
|
||||
return Ok(agentStatuses);
|
||||
return Ok(onlineAgentNames);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user