Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property measure class method defaults #4778

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

perryr16
Copy link
Contributor

@perryr16 perryr16 commented Sep 5, 2024

Any background context you want to provide?

PropertyMeasures are imported via an AT submission sync. The PropertyMeasure model has 3 choice fields (category_affected, implementation_status, and application_scale), each with a default choice.

Modify the PropertyMeasure model's class methods to handle edge cases where integer choice fields returned None. Previously, the integer fields did not allow null values, and default choices were only applied when the field was entirely omitted, not when None was returned for edge cases.

# null error
PropertyMeasure.objects.create(category_affected=None) 
# Default scenario
PropertyMeasure.objects.create()

The Berkeley data error was related to a single submission (Custom ID 1: 3100). One of the first measures brought in had an unrecognized category_affected ("OnSite..." vs "On-Site...") leading to a None value being assigned and triggered a non-null constraint. This caused the loop to exit early and prevented any other property updates.

seed_postgres  | ERROR:  null value in column "category_affected" violates not-null constraint

What's this PR do?

  • Updates the PropertyMeasure class methods to return defaults instead of None
  • Updates tests and removes developer logs

How should this be manually tested?

  • Create a 2020 cycle and upload "Berkeley 2023 Benchmarks All Fields.csv". In the mapping step, change "Berkeley Building ID" to "Custom ID 1".
  • In Org Settings, set AT credentials for a Berkeley account.
  • Trigger AT workflow from: Org Settings, Data Import, Inventory List. Confirm that 4 properties have been updated.

What are the relevant tickets?

Screenshots (if appropriate)

Copy link

github-actions bot commented Sep 5, 2024

Label error. Requires at least 1 of: Feature, Bug, Enhancement, Maintenance, Documentation, Performance, Do not publish. Found:

programatically retrieve default
@perryr16 perryr16 force-pushed the bug/at-submission-bulk-import branch from a08de25 to b814001 Compare September 5, 2024 22:21
Copy link

github-actions bot commented Sep 5, 2024

Label error. Requires at least 1 of: Feature, Bug, Enhancement, Maintenance, Documentation, Performance, Do not publish. Found:

@perryr16 perryr16 added the Bug label Sep 6, 2024
@perryr16 perryr16 marked this pull request as ready for review September 6, 2024 16:25
@kflemin kflemin merged commit 6ced1ff into develop Sep 19, 2024
9 checks passed
@kflemin kflemin deleted the bug/at-submission-bulk-import branch September 19, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants