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

BE - unit group "unit summarized" #4627

Open
ludtkemorgan opened this issue Feb 3, 2025 · 0 comments
Open

BE - unit group "unit summarized" #4627

ludtkemorgan opened this issue Feb 3, 2025 · 0 comments

Comments

@ludtkemorgan
Copy link
Collaborator

ludtkemorgan commented Feb 3, 2025

This is a follow-up ticket for the work done as part of #4523 for "unit groups"

When retrieving listings both via the "listings list" endpoint and the "listings get" endpoint a summarization of the units is calculated and added onto the response. This data is used by the public site to display the unit tables on multiple page. And because unit groups are significantly different than units as well as different data is displayed on the front end we will need to create new functions and DTO data to handle this.

In listing.service.ts the function to get one listing by id findOne retrieves the listing and then calls a function addUnitsSummarized which then in turn calls summarizeUnits. The logic for this is specific to "units" and not "unit groups".

In listing.service.ts the function to get a list of listings list gets all of the filtered listings and then adds the unit summaries via the function summarizeUnitsByTypeAndRent. The logic for this is specific to "units" and not "unit groups".

For the current system this summarization is added to the listing on a field called unitsSummarized. However, in Detroit when the groups are summarized they are added to a field called unitSummaries. When we add this logic to core we will want to use a name that is better suited that indicates it is for unit groups. Potentially unitGroupsSummarized

Note: The long term plan for this is to save the summarization in the DB on listing save so that this calculation does not have to be done for each get request. That is not part of this ticket

Changes need for this ticket:

Update DTOs to accommodate unit group summaries

  • New DTO called UnitGroupSummary with the following fields
    • sqFeetRange
    • unitVacancies
    • openWaitlist
    • amiPercentageRange
    • rentRange
    • rentAsPercentIncomeRange
    • unitTypes
  • New DTO called UnitGroupsSummarized with the following types
    • unitGroupSummary - type of UnitGroupSummary
    • householdMaxIncomeSummary - TODO: add details
  • Add unitGroupsSummarized to listing.dto.ts
    • Type of UnitGroupsSummarized

Create function to summarize unit groups

The logic between units and unit groups is different enough that we will need separate functions to summaries units vs unit groups. The appropriate function of either summarizing units or unit groups will get called based on if the feature flag created in #4523 so that on the listing there will only be either unitsSummarized or `unitGroupsSummarized.

  • This new function will take in the unit groups for a specific listing and properly set all of the fields on the unitGroupSummary DTO
  • The logic for this function can take a lot of inspiration from the current Detroit implementation
  • Note: there are separate implementations for the listing findOne vs list functions. This separation exists in both Detroit and Core. There are opportunities for consolidations of the logic, but also there could be reasons for it
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

No branches or pull requests

1 participant