Skip to content

Commit

Permalink
fix: resolve bugs from bash (#1597)
Browse files Browse the repository at this point in the history
* fix: resolve bugs from bash

* fix: paper app helper

* fix: refine helper
  • Loading branch information
ColinBuyck authored Mar 23, 2023
1 parent 0662c7e commit 53b35b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions backend/core/src/listings/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dayjs from "dayjs"
import { MinMax } from "../../types"
import { UnitGroupAmiLevelDto } from "../../src/units-summary/dto/unit-group-ami-level.dto"
import { PaperApplication } from "../../src/paper-applications/entities/paper-application.entity"

export const isDefined = (item: number | string): boolean => {
return item !== null && item !== undefined && item !== ""
Expand All @@ -19,6 +20,15 @@ export const formatDate = (rawDate: string, format: string): string => {
} else return ""
}

export const getPaperAppUrls = (paperApps: PaperApplication[]) => {
if (!paperApps || paperApps?.length === 0) return ""
const urlArr = paperApps.map((paperApplication) =>
cloudinaryPdfFromId(paperApplication.file?.fileId)
)
const formattedResults = urlArr.join(", ")
return formattedResults
}

export const getRentTypes = (amiLevels: UnitGroupAmiLevelDto[]): string => {
if (!amiLevels || amiLevels?.length === 0) return ""
const uniqueTypes = []
Expand Down
13 changes: 7 additions & 6 deletions backend/core/src/listings/listings-csv-exporter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getRentTypes,
convertToTitleCase,
formatBedroom,
getPaperAppUrls,
} from "./helpers"
@Injectable({ scope: Scope.REQUEST })
export class ListingsCsvExporterService {
Expand All @@ -37,7 +38,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 +100,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 +123,7 @@ 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": getPaperAppUrls(listing.applicationMethods[0]?.paperApplications),
"Partners Who Have Access": partnerAccessHelper[listing.id]?.join(", "),
}
})
Expand Down Expand Up @@ -152,7 +151,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)),
].join(", "),
"AMI Level": formatRange(
listing.unitGroupSummary?.amiPercentageRange?.min,
listing.unitGroupSummary?.amiPercentageRange?.max,
Expand Down

0 comments on commit 53b35b8

Please sign in to comment.