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: resolve bugs from bash #1597

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions backend/core/src/listings/listings-csv-exporter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ListingsCsvExporterService {
"Verified Date": formatDate(listing.verifiedAt, "MM-DD-YYYY hh:mm:ssA"),
"Last Updated": formatDate(listing.updatedAt, "MM-DD-YYYY hh:mm:ssA"),
"Listing Name": listing.name,
"Developer Property Owner": listing.property.developer,
"Developer/Property Owner": listing.property.developer,
"Street Address": listing.property.buildingAddress?.street,
City: listing.property.buildingAddress?.city,
State: listing.property.buildingAddress?.state,
Expand Down Expand Up @@ -99,7 +99,7 @@ export class ListingsCsvExporterService {
"Marketing Status": convertToTitleCase(listing.marketingType),
"Marketing Season": convertToTitleCase(listing.marketingSeason),
"Marketing Date": formatDate(listing.marketingDate, "YYYY"),
"Leasing Company": listing.managementCompany,
"Leasing Company": listing.leasingAgentName,
"Leasing Email": listing.leasingAgentEmail,
"Leasing Phone": listing.leasingAgentPhone,
"Leasing Agent Title": listing.leasingAgentTitle,
Expand All @@ -122,9 +122,9 @@ export class ListingsCsvExporterService {
"Digital Application": formatYesNo(listing.digitalApplication),
"Digital Application URL": listing.applicationMethods[1]?.externalReference,
"Paper Application": formatYesNo(listing.paperApplication),
"Paper Application URL": cloudinaryPdfFromId(
listing.applicationMethods[0]?.paperApplications[0]?.file?.fileId
),
"Paper Application URL": listing.applicationMethods[0]?.paperApplications
YazeedLoonat marked this conversation as resolved.
Show resolved Hide resolved
.map((paperApplication) => cloudinaryPdfFromId(paperApplication.file?.fileId))
.join(", "),
"Partners Who Have Access": partnerAccessHelper[listing.id]?.join(", "),
}
})
Expand Down Expand Up @@ -152,7 +152,9 @@ export class ListingsCsvExporterService {
"Unit Types": listing.unitGroupSummary?.unitTypes
.map((unitType) => formatBedroom[unitType])
.join(", "),
"AMI Chart": listing.unitGroup?.amiLevels.map((level) => level.amiChart?.name).join(", "),
"AMI Chart": [
...new Set(listing.unitGroup?.amiLevels.map((level) => level.amiChart?.name)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

this for sure works, I think its not the most efficient approach though.

could we instead use a .reduce here and verify uniqueness in the accumulator ourselves then join that together?

Copy link
Collaborator Author

@ColinBuyck ColinBuyck Mar 22, 2023

Choose a reason for hiding this comment

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

So I had gone back and forth on this decision here in development... I was feeling that using reduce() as a filter/map replacement sacrifices more readability than it would gain in efficiency (if I'm understanding correctly that it would have a linear runtime either way, just one less iteration). The lack of readability is coming from my personal difficulty in reading reduce functions that aren't reducing an array to a single value as intended. Much of this was inspired by this video and basically summarized here. Can also recognize that using set in this way may be less readable than a map + filter combo which I could also do and would definitely pull out into a helper. I'm totally good to change this to any of these, but just wanted to get your thoughts on these pieces first and see what you'd prefer @YazeedLoonat

].join(", "),
"AMI Level": formatRange(
listing.unitGroupSummary?.amiPercentageRange?.min,
listing.unitGroupSummary?.amiPercentageRange?.max,
Expand Down