Skip to content

Fix: Estimated AQI now matches Current AQI when Scenario Simulator sliders are at 0%#114

Merged
Aditya8369 merged 1 commit into
Aditya8369:mainfrom
AimaMuzammil:fix/issue-113-scenario-simulator-aqi
Jul 9, 2026
Merged

Fix: Estimated AQI now matches Current AQI when Scenario Simulator sliders are at 0%#114
Aditya8369 merged 1 commit into
Aditya8369:mainfrom
AimaMuzammil:fix/issue-113-scenario-simulator-aqi

Conversation

@AimaMuzammil

@AimaMuzammil AimaMuzammil commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #113 — The Scenario Simulator was showing a reduced "Estimated AQI"
even when all intervention sliders were at 0% and no policy scenario was
selected.

Root Cause

The estimatedAqi value was always recalculated using the local
estimateAQI() function, even when no reduction was applied. Since this
function uses a different formula than the one used by the Open-Meteo API
(which provides current.us_aqi), the two values could differ slightly
even with identical pollutant inputs.

Fix

Added a hasReduction check: if all sliders are at 0% (no reduction
selected), estimatedAqi now uses current.us_aqi directly instead of
recalculating it. The same fix was applied to the simulateCity()
function used for the city comparison cards, to prevent the same issue
there.

Testing Done

  • ✅ With all sliders at 0%: Current AQI and Estimated AQI now match exactly
  • ✅ Tested all 5 presets (Traffic Control, Industrial Limits, Green Cover,
    Clean Fuel Switch, Combined Policy) — Estimated AQI still correctly
    decreases based on the selected reduction
  • ✅ Tested city comparison cards (Delhi, Mumbai, Bengaluru, Kolkata,
    Chennai, Hyderabad) — all showing correct before/after values

Before (bug):
Sliders at 0%, but Estimated AQI shows a fake -29% reduction (77 → 55)
Screenshot 2026-07-09 121940

After (fixed):
Sliders at 0%, Current AQI and Estimated AQI now match exactly (77 → 77)
Screenshot 2026-07-09 121022


I'm an ECSoC'26 contributor in the UI Components track.

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@AimaMuzammil is attempting to deploy a commit to the Aditya Mahajan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@AimaMuzammil

Copy link
Copy Markdown
Contributor Author

Hi @Aditya8369! This PR fixes Issue #113. Could you please review it
whenever you get a chance, and add the ECSoC26 label if everything looks
good? Thank you!

@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pollution-control-hub Ready Ready Preview, Comment Jul 9, 2026 2:14pm

@Aditya8369 Aditya8369 merged commit e251e0f into Aditya8369:main Jul 9, 2026
3 checks passed
@Aditya8369 Aditya8369 added the ECSoC26 Contributions considered under ECSoC'26 label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🎉 Your PR just got merged, @AimaMuzammil — thank you for contributing to Pollution Control Hub!

Your work is now part of the project. Here's what to do next:

  • ⭐ If you haven't already, consider giving the repo a star — it helps us grow.
  • 📢 Share your contribution on LinkedIn, Twitter, or wherever you hang out. You shipped open source!
  • 🔍 Browse other open issues if you want to keep contributing.

We really appreciate you taking the time. See you in the next PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26-L1 ECSoC26 Contributions considered under ECSoC'26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Estimated AQI shows a reduction even when Scenario Simulator sliders are at 0%

2 participants