Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
[HttpGet("getLatestValidHeatmap")]
public async Task<ActionResult<String>> GetLatestValidHeatmap()
{
var latestTimestamp = await _context.DetectedDevice
.MaxAsync(x => x.Timestamp);

var detectedDevices = await _context.DetectedDevice
.GroupBy(x => x.Timestamp)
.Select(g => g.OrderByDescending(x => x.Timestamp).First())
.Where(x => x.Timestamp == latestTimestamp)
.ToListAsync();

if (detectedDevices.IsNullOrEmpty())
Expand All @@ -68,7 +70,7 @@
return await GetDetectedDeviceTimestampHelper(detectedDevices);
}

private async Task<ActionResult<String>> GetDetectedDeviceTimestampHelper(List<DetectedDevice> detectedDevices)

Check warning on line 73 in CrowdedBackend/CrowdedBackend/Controllers/DetectedDevicesController.cs

View workflow job for this annotation

GitHub Actions / format-check

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
List<(float x, float y)> listOfDeviceLocations = [];
foreach (var detectedDevice in detectedDevices)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ await PostRaspData(new RaspData
// Notify clients
await _hubContext.Clients.All.SendAsync("NewDevicesDetected", new
{
Devices = points.Select(p => new { X = p.X, Y = p.Y, Timestamp = now })
Devices = points.Count
});

_circleUtils.WipeData();
Expand Down
Loading