Skip to content

Commit

Permalink
Fixed SonarCloud issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
brenordv committed Dec 17, 2024
1 parent 62da565 commit 29e49c6
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Raccoon.Ninja.AzFn.DataApi/DataApiFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Raccoon.Ninja.AzFn.DataApi;

public class DataApiFunc
{
private const int maxItems = 1;
private readonly ILogger _logger;

public DataApiFunc(ILogger<DataApiFunc> logger)
Expand Down Expand Up @@ -70,21 +69,15 @@ public async Task<IActionResult> RunAsync(
new QueryDefinition("SELECT TOP 1 * FROM c ORDER BY c.readAt DESC")
);

var docsFetched = 0;
while (iteratorLatestReading.HasMoreResults)
{
var response = await iteratorLatestReading.ReadNextAsync();
var latestReading = response.FirstOrDefault();

if (latestReading is not null)
{
results.Add(latestReading);
return new OkObjectResult(results);
}
if (latestReading is null) continue;

docsFetched++;
if (docsFetched >= maxItems)
break;
results.Add(latestReading);
return new OkObjectResult(results);
}

return new NoContentResult();
Expand Down

0 comments on commit 29e49c6

Please sign in to comment.