Skip to content

Automated PR feature/implementing-logger into Main#23

Merged
joaoferreira-dev merged 1 commit into
mainfrom
feature/implementing-logger
Feb 15, 2026
Merged

Automated PR feature/implementing-logger into Main#23
joaoferreira-dev merged 1 commit into
mainfrom
feature/implementing-logger

Conversation

@github-actions
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces structured logging into the StationController and ReadingController API endpoints, and updates the associated controller unit tests to construct controllers with an injected ILogger.

Changes:

  • Add ILogger<T> constructor injection to StationController and ReadingController.
  • Add LogInformation/LogWarning/LogError/LogDebug statements around key controller actions and error paths.
  • Update controller tests to pass mocked ILogger<T> instances.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
AirAware/Controllers/StationController.cs Adds injected logger and logs around station CRUD and latest-AQI endpoint.
AirAware/Controllers/ReadingController.cs Adds injected logger and logs around reading CRUD, raw payload parsing, and AQI creation.
AirAware.Tests/Controllers/StationControllerTests.cs Updates test setup to construct StationController with a mocked logger.
AirAware.Tests/Controllers/ReadingControllerTests.cs Updates test setup to construct ReadingController with a mocked logger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// Get latest AQI record for this station, including its reading
var latest = await context.AqiRecords
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query starting here orders AqiRecords before a Join(...). Ordering is not guaranteed to be preserved through a join, so with the later FirstOrDefaultAsync() this can return a non-latest record. Apply the ordering after the join/selection (e.g., order by ar.Aqi.ComputedAt right before FirstOrDefaultAsync).

Copilot uses AI. Check for mistakes.
_logger.LogDebug("AQI record already exists for reading {ReadingId}", reading.Id);
}

return Created($"api/v1/readings/{reading.Id}", new { reading, aqi = aqiRecord });
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an AQI record already exists for this ReadingId, the response still returns the newly computed aqiRecord instance, which may not match what’s persisted (and ignores existing). Consider returning existing when present (or overwriting it) so the API response reflects the stored data.

Copilot uses AI. Check for mistakes.
@joaoferreira-dev joaoferreira-dev merged commit 5494e14 into main Feb 15, 2026
7 checks passed
@joaoferreira-dev joaoferreira-dev deleted the feature/implementing-logger branch February 15, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add logger to application for observability

2 participants