From 5be0b22c52b96cffd2eb3b5d3cd62da3be719b52 Mon Sep 17 00:00:00 2001 From: ColinBuyck <53269332+ColinBuyck@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:53:25 -0700 Subject: [PATCH] fix: resolve bugs from bash (#1597) * fix: resolve bugs from bash * fix: paper app helper * fix: refine helper --- backend/core/src/listings/helpers.ts | 10 ++++++++++ .../src/listings/listings-csv-exporter.service.ts | 13 +++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/core/src/listings/helpers.ts b/backend/core/src/listings/helpers.ts index c5583bced7..35d4cadf9c 100644 --- a/backend/core/src/listings/helpers.ts +++ b/backend/core/src/listings/helpers.ts @@ -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 !== "" @@ -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 = [] diff --git a/backend/core/src/listings/listings-csv-exporter.service.ts b/backend/core/src/listings/listings-csv-exporter.service.ts index e8514ed228..9b01a15b72 100644 --- a/backend/core/src/listings/listings-csv-exporter.service.ts +++ b/backend/core/src/listings/listings-csv-exporter.service.ts @@ -11,6 +11,7 @@ import { getRentTypes, convertToTitleCase, formatBedroom, + getPaperAppUrls, } from "./helpers" @Injectable({ scope: Scope.REQUEST }) export class ListingsCsvExporterService { @@ -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, @@ -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, @@ -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(", "), } }) @@ -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,