From 8d9d07d3ffde8f7bedcdd3646cf00f9cc88aafc2 Mon Sep 17 00:00:00 2001 From: ColinBuyck Date: Tue, 21 Mar 2023 15:58:12 -0700 Subject: [PATCH 1/3] fix: resolve bugs from bash --- .../src/listings/listings-csv-exporter.service.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/core/src/listings/listings-csv-exporter.service.ts b/backend/core/src/listings/listings-csv-exporter.service.ts index e8514ed228..8bd8112c25 100644 --- a/backend/core/src/listings/listings-csv-exporter.service.ts +++ b/backend/core/src/listings/listings-csv-exporter.service.ts @@ -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, @@ -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, @@ -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 + .map((paperApplication) => cloudinaryPdfFromId(paperApplication.file?.fileId)) + .join(", "), "Partners Who Have Access": partnerAccessHelper[listing.id]?.join(", "), } }) @@ -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)), + ].join(", "), "AMI Level": formatRange( listing.unitGroupSummary?.amiPercentageRange?.min, listing.unitGroupSummary?.amiPercentageRange?.max, From 0bae8508169d62ffc4425490fba285c9e8603f51 Mon Sep 17 00:00:00 2001 From: ColinBuyck Date: Wed, 22 Mar 2023 16:24:45 -0700 Subject: [PATCH 2/3] fix: paper app helper --- backend/core/src/listings/helpers.ts | 8 ++++++++ .../core/src/listings/listings-csv-exporter.service.ts | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/core/src/listings/helpers.ts b/backend/core/src/listings/helpers.ts index c5583bced7..19a389a8ac 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,13 @@ export const formatDate = (rawDate: string, format: string): string => { } else return "" } +export const getPaperAppUrls = (paperApps: PaperApplication[]) => { + if (!paperApps || paperApps?.length === 0) return "" + return paperApps + .map((paperApplication) => cloudinaryPdfFromId(paperApplication.file?.fileId)) + .join(", ") +} + 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 8bd8112c25..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 { @@ -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": listing.applicationMethods[0]?.paperApplications - .map((paperApplication) => cloudinaryPdfFromId(paperApplication.file?.fileId)) - .join(", "), + "Paper Application URL": getPaperAppUrls(listing.applicationMethods[0]?.paperApplications), "Partners Who Have Access": partnerAccessHelper[listing.id]?.join(", "), } }) From b34bb307c345844d55ff80d35aa6de7c18ea9ad8 Mon Sep 17 00:00:00 2001 From: ColinBuyck Date: Wed, 22 Mar 2023 16:35:08 -0700 Subject: [PATCH 3/3] fix: refine helper --- backend/core/src/listings/helpers.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/core/src/listings/helpers.ts b/backend/core/src/listings/helpers.ts index 19a389a8ac..35d4cadf9c 100644 --- a/backend/core/src/listings/helpers.ts +++ b/backend/core/src/listings/helpers.ts @@ -22,9 +22,11 @@ export const formatDate = (rawDate: string, format: string): string => { export const getPaperAppUrls = (paperApps: PaperApplication[]) => { if (!paperApps || paperApps?.length === 0) return "" - return paperApps - .map((paperApplication) => cloudinaryPdfFromId(paperApplication.file?.fileId)) - .join(", ") + const urlArr = paperApps.map((paperApplication) => + cloudinaryPdfFromId(paperApplication.file?.fileId) + ) + const formattedResults = urlArr.join(", ") + return formattedResults } export const getRentTypes = (amiLevels: UnitGroupAmiLevelDto[]): string => {