Skip to content

Automated PR feature/calculate-aqi-service into Main#16

Merged
joaoferreira-dev merged 6 commits into
mainfrom
feature/calculate-aqi-service
Feb 8, 2026
Merged

Automated PR feature/calculate-aqi-service into Main#16
joaoferreira-dev merged 6 commits into
mainfrom
feature/calculate-aqi-service

Conversation

@github-actions
Copy link
Copy Markdown

@github-actions github-actions Bot commented Feb 8, 2026

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

Adds an AQI calculation service and persistence so the API can compute AQI on reading ingest and expose a “latest AQI for station” endpoint.

Changes:

  • Renames PM2.5 field from Pm2_5 to Pm25 across view model/model usage.
  • Introduces IAqiCalculator + EpaAqiCalculator and wires it into DI to compute/store AqiRecord on POST /api/v1/readings.
  • Adds AqiRecords EF DbSet + a new GET /api/v1/stations/{id}/aqi/latest endpoint.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
AirAware/ViewModels/CreateReadingViewModel.cs Renames inbound PM2.5 field to Pm25.
AirAware/Models/Reading.cs Renames persisted PM2.5 property to Pm25.
AirAware/Services/IAqiCalculator.cs Adds AQI calculator interface + AqiResult.
AirAware/Services/AqiCalculator.cs Implements EPA breakpoint-based AQI calculation.
AirAware/Models/AqiRecord.cs Adds persisted AQI record model.
AirAware/Data/AppDbContext.cs Adds DbSet<AqiRecord> to EF context.
AirAware/Startup.cs Registers AQI calculator in DI.
AirAware/Controllers/ReadingController.cs Computes AQI and writes an AqiRecord on reading ingest.
AirAware/Controllers/StationController.cs Adds endpoint to fetch the latest AQI for a station.

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

Comment thread AirAware/Services/AqiCalculator.cs Outdated
Comment thread AirAware/Controllers/ReadingController.cs Outdated
Comment thread AirAware/Controllers/ReadingController.cs Outdated
Comment thread AirAware/Controllers/ReadingController.cs Outdated
Comment on lines 92 to +97
await context.Readings.AddAsync(reading);
await context.SaveChangesAsync();
return Created($"api/v1/readings/{reading.Id}", reading);

// compute AQI synchronously
var (final, pm25Result, pm10Result) = aqiCalculator.Calculate(reading);

Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

Readings are saved, then AqiRecords are saved in a separate SaveChangesAsync() without a transaction. If the AQI insert fails, you’ll persist a reading without its AQI record. Consider adding the AqiRecord to the context and saving both in a single SaveChangesAsync() (or use an explicit transaction).

Copilot uses AI. Check for mistakes.
Comment thread AirAware/Controllers/ReadingController.cs
Comment thread AirAware/Controllers/ReadingController.cs
Comment thread AirAware/ViewModels/CreateReadingViewModel.cs
Comment thread AirAware/Data/AppDbContext.cs
Comment thread AirAware/Services/IAqiCalculator.cs Outdated
@joaoferreira-dev joaoferreira-dev merged commit a8c5912 into main Feb 8, 2026
1 check passed
@joaoferreira-dev joaoferreira-dev deleted the feature/calculate-aqi-service branch February 8, 2026 18:47
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.

Analyze API integration for Readings in Air Quality Service

2 participants