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

fix: unit tables multiple rows for same rent type, sorting issues #1306

Merged

Conversation

emilyjablonski
Copy link
Collaborator

@emilyjablonski emilyjablonski commented Jun 1, 2021

Pull Request Template

Issue

Addresses HBA#247 #1297

  • This change addresses the issue in full
  • This change addresses only certain aspects of the issue
  • This change is a dependency for another issue
  • This change has a dependency from another issue

Description

This PR tackles two issues. The first is that when I made the change to show multiple rows for different rent types (% income vs static number), it also ended up showing multiple rows for the same type if the values were different. For example, Coliseum appeared as below with the bug. There should be two rows for 2 BR, not three. The different static rent numbers should appear as a range.
Screen Shot 2021-06-01 at 5 31 23 PM

With this fix, it now appears as below.
Screen Shot 2021-06-01 at 5 31 31 PM

The second issue this solves is unit summaries coming through unsorted (see the linked issues).

I also just tried my best to clean up the fxns, they were confusing.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Prototype/POC (not to merge)
  • This change is a refactor/address technical debt
  • This change requires a documentation update
  • This change requires a SQL Script

How Can This Be Tested/Reviewed?

Import a listing with rent ranges, like Coliseum. Check out the unit summaries table, the occupancy ranges, and the floor ranges.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have reviewed the changes in a desktop view
  • I have reviewed the changes in a mobile view
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have assigned reviewers
  • I have updated the changelog to include a description of my changes

@emilyjablonski emilyjablonski added the wip This PR is not ready for review, do not review it's a “Work In Progress” label Jun 1, 2021
@emilyjablonski emilyjablonski changed the title fix/unit tables multiple rows for same rent type, sorting issues fix: unit tables multiple rows for same rent type, sorting issues Jun 1, 2021
@netlify
Copy link

netlify bot commented Jun 1, 2021

✔️ Deploy Preview for clever-edison-cd22c1 ready!

🔨 Explore the source changes: 70685bc

🔍 Inspect the deploy log: https://app.netlify.com/sites/clever-edison-cd22c1/deploys/60bfd4491e41330008b156a2

😎 Browse the preview: https://deploy-preview-1306--clever-edison-cd22c1.netlify.app

@emilyjablonski emilyjablonski linked an issue Jun 1, 2021 that may be closed by this pull request
@emilyjablonski emilyjablonski force-pushed the fix/unit-tables-multiple-rows-for-same-rent-type branch from ae1d6d7 to 591461a Compare June 1, 2021 23:55
@emilyjablonski emilyjablonski marked this pull request as ready for review June 2, 2021 22:04
@emilyjablonski emilyjablonski force-pushed the fix/unit-tables-multiple-rows-for-same-rent-type branch from c8632fc to 350b524 Compare June 2, 2021 22:05
@emilyjablonski emilyjablonski added ready for review and removed wip This PR is not ready for review, do not review it's a “Work In Progress” labels Jun 2, 2021
Copy link
Collaborator

@jaredcwhite jaredcwhite left a comment

Choose a reason for hiding this comment

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

Just saw one typo. Otherwise, changes make sense. I'm wondering if we can further break this file out into more discrete functions/constants? LOC is creeping ever higher…

{
min: parseFloat(summary.minIncomeRange?.min),
max: parseFloat(summary.minIncomeRange?.max),
const getCurrenyString = (initialValue: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

⬆️ typo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, thanks!

@emilyjablonski
Copy link
Collaborator Author

Curious what you would suggest breaking out? (Also does LOC stand for lines of code?)

@jaredcwhite
Copy link
Collaborator

Yeah, Lines of Code. So basically anything that isn't directly performing the data transformations specific to unit sumamries/hmi/etc. I would recommend breaking out (and this isn't anything specific to your work, looks like the file's been touched by a bunch of people and there might be some stuff lurking underneath I originally worked on).

Suggestions:

  • We can remove AnyDict and just use TS's Record
  • usd could be extracted for use elsewhere. also minMax, minMaxCurrency, getRoundedNumber, etc.
  • bmrHeaders, UnitTypeSort, etc. feel like constants that could be all defined in one centralized location
  • UnitMap move to a types folder?

@emilyjablonski
Copy link
Collaborator Author

That all makes a ton of sense! Thank you for taking a look and giving me context :)

@jaredcwhite
Copy link
Collaborator

Sure, np :)

Copy link
Collaborator

@seanmalbert seanmalbert left a comment

Choose a reason for hiding this comment

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

Hey @emilyjablonski , this looks good. I generally agree with @jaredcwhite 's comments, though I'm not sure how much of it we want to do here. For UnitTypeSort for example, I created a separate issue to convert unitType to an enum and have UnitTypeSort be replaced with that.

I have a question on the summaries sort too.

return summary
}

type UnitMap = {
[key: string]: Unit[]
}

const UnitTypeSort = ["studio", "oneBdrm", "twoBdrm", "threeBdrm"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be moved to an enum that unitType also uses on the unit entity. I don't think we need to do this right now with this task though, so I created this issue #1335

return summaries.filter((item) => Object.keys(item).length > 0)
return summaries.sort((a, b) => {
return (
UnitTypeSort.indexOf(a.unitType[0]) - UnitTypeSort.indexOf(b.unitType[0]) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the value of unitType a string here, like "threeBdrm"? If that's the case, then a.unitType[0] would be "t" in this example.

Copy link
Collaborator Author

@emilyjablonski emilyjablonski Jun 7, 2021

Choose a reason for hiding this comment

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

It's the index of the string in the array, so the value is a number - double checking this now to see if I goofed!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should be all set now 👍 I think the reason this typo didn't create any visible issues is because the income is also tied pretty deeply to unit size, and we don't have any units right now where unit would be a tie breaker for income

@emilyjablonski emilyjablonski force-pushed the fix/unit-tables-multiple-rows-for-same-rent-type branch from e5ef479 to 2793aa8 Compare June 8, 2021 01:31
@emilyjablonski emilyjablonski force-pushed the fix/unit-tables-multiple-rows-for-same-rent-type branch from 2793aa8 to 70685bc Compare June 8, 2021 20:34
@emilyjablonski emilyjablonski merged commit 9be5342 into master Jun 8, 2021
@emilyjablonski emilyjablonski deleted the fix/unit-tables-multiple-rows-for-same-rent-type branch June 8, 2021 20:54
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.

Units out of order for Coliseum
3 participants