Skip to content

Commit df1c3e4

Browse files
authored
fix: change csv dates to sortable format (#5917)
1 parent 3d4d3d9 commit df1c3e4

12 files changed

+34
-17
lines changed

api/prisma/seed-helpers/application-factory.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
YesNoEnum,
88
MultiselectQuestionsApplicationSectionEnum,
99
} from '@prisma/client';
10+
import dayjs from 'dayjs';
11+
import { randomInt } from 'crypto';
1012
import { generateConfirmationCode } from '../../src/utilities/applications-utilities';
1113
import { addressFactory } from './address-factory';
1214
import { randomNoun } from './word-generator';
@@ -56,16 +58,23 @@ export const applicationFactory = async (optionalParams?: {
5658
if (optionalParams?.householdMember) {
5759
householdSize = optionalParams.householdMember.length + 1;
5860
}
61+
const createdAtDate =
62+
optionalParams?.createdAt ||
63+
// Created at date sometime in the last 2 months
64+
dayjs(new Date()).subtract(randomInt(87_600), 'minutes').toDate();
5965
return {
60-
createdAt: optionalParams?.createdAt || new Date(),
66+
createdAt: createdAtDate,
6167
confirmationCode: generateConfirmationCode(),
6268
applicant: { create: applicantFactory(optionalParams?.applicant) },
6369
appUrl: '',
6470
status: ApplicationStatusEnum.submitted,
6571
submissionType:
6672
optionalParams?.submissionType ??
6773
ApplicationSubmissionTypeEnum.electronical,
68-
submissionDate: new Date(),
74+
submissionDate:
75+
optionalParams?.submissionType !== ApplicationSubmissionTypeEnum.paper
76+
? createdAtDate
77+
: dayjs(createdAtDate).add(2, 'days').toDate(),
6978
householdSize: householdSize,
7079
income: '40000',
7180
incomePeriod: randomBoolean()

api/prisma/seed-helpers/listing-data/district-view-apartments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const districtViewApartments: Prisma.ListingsCreateInput = {
7777
waitlistOpenSpots: null,
7878
customMapPin: false,
7979
contentUpdatedAt: new Date(),
80-
publishedAt: new Date(),
80+
publishedAt: dayjs(new Date()).subtract(2, 'months').toDate(),
8181
listingsApplicationPickUpAddress: undefined,
8282
listingsApplicationDropOffAddress: undefined,
8383
listingsApplicationMailingAddress: undefined,

api/prisma/seed-helpers/listing-data/elm-village.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export const elmVillage: Prisma.ListingsCreateInput = {
8787
waitlistOpenSpots: null,
8888
customMapPin: false,
8989
contentUpdatedAt: new Date(),
90-
publishedAt: new Date(),
90+
publishedAt: dayjs(new Date())
91+
.subtract(1, 'months')
92+
.subtract(3, 'days')
93+
.subtract(12, 'minutes')
94+
.toDate(),
9195
listingsApplicationPickUpAddress: undefined,
9296
listingsApplicationDropOffAddress: undefined,
9397
reservedCommunityTypes: undefined,

api/prisma/seed-helpers/listing-data/hollywood-hills-heights.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ReviewOrderTypeEnum,
66
} from '@prisma/client';
77
import { yellowstoneAddress } from '../address-factory';
8+
import dayjs from 'dayjs';
89

910
export const hollywoodHillsHeights: Prisma.ListingsCreateInput = {
1011
additionalApplicationSubmissionNotes: null,
@@ -75,7 +76,10 @@ export const hollywoodHillsHeights: Prisma.ListingsCreateInput = {
7576
waitlistOpenSpots: null,
7677
customMapPin: false,
7778
contentUpdatedAt: new Date(),
78-
publishedAt: new Date(),
79+
publishedAt: dayjs(new Date())
80+
.subtract(1, 'months')
81+
.subtract(1, 'days')
82+
.toDate(),
7983
listingsBuildingAddress: {
8084
create: yellowstoneAddress,
8185
},

api/prisma/seed-helpers/listing-data/lakeview-villa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const lakeviewVilla: Prisma.ListingsCreateInput = {
7777
waitlistOpenSpots: null,
7878
customMapPin: false,
7979
contentUpdatedAt: new Date(),
80-
publishedAt: new Date(),
80+
publishedAt: dayjs(new Date()).subtract(22, 'minutes').toDate(),
8181
listingsBuildingAddress: {
8282
create: yellowstoneAddress,
8383
},

api/prisma/seed-helpers/listing-data/little-village-apartments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const littleVillageApartments: Prisma.ListingsCreateInput = {
7373
waitlistOpenSpots: 6,
7474
customMapPin: false,
7575
contentUpdatedAt: new Date(),
76-
publishedAt: new Date(),
76+
publishedAt: dayjs(new Date()).subtract(19, 'seconds').toDate(),
7777
listingsApplicationPickUpAddress: undefined,
7878
listingsApplicationDropOffAddress: undefined,
7979
listingsApplicationMailingAddress: undefined,

api/prisma/seed-helpers/listing-data/sunshine-flats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const sunshineFlats: Prisma.ListingsCreateInput = {
7575
waitlistOpenSpots: null,
7676
customMapPin: false,
7777
contentUpdatedAt: new Date(),
78-
publishedAt: new Date(),
78+
publishedAt: dayjs(new Date()).subtract(12, 'hours').toDate(),
7979
listingsBuildingAddress: {
8080
create: glacierAddress,
8181
},

api/prisma/seed-helpers/listing-data/valley-heights-senior-community.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const valleyHeightsSeniorCommunity: Prisma.ListingsCreateInput = {
7474
waitlistOpenSpots: null,
7575
customMapPin: false,
7676
contentUpdatedAt: dayjs(new Date()).subtract(1, 'days').toDate(),
77-
publishedAt: dayjs(new Date()).subtract(3, 'days').toDate(),
77+
publishedAt: dayjs(new Date()).subtract(3, 'months').toDate(),
7878
closedAt: dayjs(new Date()).subtract(5, 'days').toDate(),
7979
listingsApplicationPickUpAddress: undefined,
8080
listingsLeasingAgentAddress: undefined,

api/src/services/listing-csv-export.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const formatCloudinaryPdfUrl = (fileId: string): string => {
103103

104104
@Injectable()
105105
export class ListingCsvExporterService implements CsvExporterServiceInterface {
106-
readonly dateFormat: string = 'MM-DD-YYYY hh:mm:ssA z';
106+
readonly dateFormat: string = 'YYYY-MM-DD hh:mm:ss A';
107107
timeZone = process.env.TIME_ZONE;
108108
constructor(
109109
private prisma: PrismaService,

api/src/utilities/application-export-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const getExportHeaders = (
2727
user: User,
2828
includeDemographics = false,
2929
forLottery = false,
30-
dateFormat = 'MM-DD-YYYY hh:mm:ssA z',
30+
dateFormat = 'YYYY-MM-DD hh:mm:ss A',
3131
swapCommunityTypeWithPrograms?: boolean,
3232
): CsvHeader[] => {
3333
const enableAdaOtherOption = doAnyJurisdictionHaveFeatureFlagSet(

0 commit comments

Comments
 (0)