diff --git a/CHANGELOG.md b/CHANGELOG.md index 05ddf3a40aeb84685e5f97f409d3abbc2d35adb4..6dcbe6a513950e32b1e3c53691a4c9712136806b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 1.3.1 - 2018-06-19 +### Changed +- Fixed bug with Federal District and missing cities in classroom count + ## 1.3.0 - 2018-06-18 ### Added - Daily charge amount route diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index efb64d267dc622d1bb9c41059d2c25a205e2dd85..3b519e335642a1a7461024acd540c052a07f3542 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -246,6 +246,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let result = []; let hashSet = new Set(); let enrollments = [...req.enrollment]; + let leftovers = []; while (i < req.classroom.length) { let classroom = req.classroom[i]; // Cria hash única para cada espacialidade, dado um ano @@ -305,7 +306,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { enrollmentMatch = false; continue; } else if(classroom.city_name > enrollment.city_name) { - ++j; + let enrollmentHash = '' + enrollment.year + enrollment.state_id + enrollment.city_id; + if(hashSet.has(enrollmentHash)) { + leftovers.push(enrollments.splice(j, 1)); // Para inspeção, adiciona os que "sobram" no array de sobras + } else { + ++j; + } continue; }