Repository navigation
Fix/floor area building first - #22
Merged
Merged
Conversation
get_total_floor_area checked Site FloorAreas before Building, so a Site value overrode the Building's own value. Check the more specific Building first and fall back to Site, matching the method comment. Add specs for Building only, Site only, and both present. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reader calls BOSS.BOSS_logger and uses ASHRAE90_1 and other constants, but relied on other files to load them. Running buildingsync_reader_spec.rb on its own failed with "undefined method `BOSS_logger' for BOSS:Module". Require both directly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The unguarded Building lookup raises NoMethodError for Site-only documents before reaching the area fallback, and the new spec’s empty Building element leaves this regression untested.
1 open issue
What changed in this PR
This PR makes BuildingSync floor-area selection prefer the Building’s value over the Site’s value and adds direct dependencies for standalone reader use.
Changes:
- Checks Building floor area first, falling back to Site.
- Adds specs for Building-only values, Site fallback, and precedence when both have values.
- Documents the precedence and explicitly requires the logger and constants.
| File | Description |
|---|---|
spec/tests/unit/buildingsync_reader_spec.rb |
Adds three floor-area selection specs. |
README.md |
Documents Building-over-Site precedence. |
lib/BOSS/buildingsync_reader/buildingsync_reader.rb |
Reorders floor-area lookup and adds direct dependency requires. |
Review effort: Balanced
| # check building floor area | ||
| BOSS.BOSS_logger.info("#{"|\t"*num_indent}- checking building for total floor area...") | ||
| building_floor_areas_xml = @building_xml.elements["#{@ns}FloorAreas"] | ||
| building_area = !building_floor_areas_xml.nil? ? _get_total_floor_area_from_floor_areas_xml(building_floor_areas_xml, num_indent+1) : 0 | ||
| BOSS.BOSS_logger.info("#{"|\t"*num_indent} building floor area is #{building_area}") | ||
| return building_area if building_area > 0 | ||
|
|
||
| # check site floor area | ||
| BOSS.BOSS_logger.info("#{"|\t"*num_indent}- checking site for total floor area...") | ||
| site_floor_areas_xml = @site_xml.elements["#{@ns}FloorAreas"] |
Contributor
There was a problem hiding this comment.
Fixed in bcf2317 by guarding the Building floor-area lookup and adding a Site-only regression spec.
Co-authored-by: kflemin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

get_total_floor_areacheckedSite/FloorAreasbeforeBuilding/FloorAreas, so a Site value overrode the Building's own floor area. The method comment already said Building should come first. BuildingSync tools should use the most specific value when both are present.buildingsync_reader_spec.rbfailed when run on its own (undefined method 'BOSS_logger' for BOSS:Module). The reader relied on other files to load the logger and constants.What this does
get_total_floor_areablock).BOSS/boss_loggerandBOSS/constantsdirectly inbuildingsync_reader.rb.