From bf10632a62bf2f14922948c046ea3352ed010f4f Mon Sep 17 00:00:00 2001 From: Emily Jablonski <65367387+emilyjablonski@users.noreply.github.com> Date: Fri, 12 Nov 2021 13:16:58 -0700 Subject: [PATCH] refactor: remove applicationAddress (#2009) * refactor: remove applicationAddress * docs: readme update * test: fix backend test * fix: db migration * Fix code style issues with Prettier * test(backend): fix SETEX impossible to process Co-authored-by: Lint Action Co-authored-by: Michal Plebanski Co-authored-by: Sean Albert --- CHANGELOG.md | 1 + backend/core/archer.ts | 11 ----------- .../src/listings/dto/listing-create.dto.ts | 5 ----- .../src/listings/dto/listing-update.dto.ts | 5 ----- backend/core/src/listings/dto/listing.dto.ts | 7 ------- .../src/listings/entities/listing.entity.ts | 7 ------- backend/core/src/listings/listings.module.ts | 1 + backend/core/src/listings/views/config.ts | 3 --- .../1634316081536-remove-app-address.ts | 19 +++++++++++++++++++ .../seeds/listings/listing-coliseum-seed.ts | 9 --------- .../src/seeds/listings/listing-triton-seed.ts | 8 -------- backend/core/src/seeds/listings/shared.ts | 9 --------- backend/core/test/factories/listing.ts | 9 --------- .../core/test/listings/listings.e2e-spec.ts | 2 +- backend/core/types/src/archer-listing.ts | 11 ----------- backend/core/types/src/backend-swagger.ts | 10 ---------- .../src/listings/PaperListingForm/index.tsx | 1 - sites/public/cypress/fixtures/listing.json | 8 -------- ui-components/__tests__/fixtures/archer.json | 8 -------- ui-components/__tests__/fixtures/gish.json | 8 -------- .../__tests__/fixtures/triton-test.json | 8 -------- .../page_components/SidebarAddress.test.tsx | 4 ++-- 22 files changed, 24 insertions(+), 130 deletions(-) create mode 100644 backend/core/src/migration/1634316081536-remove-app-address.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3776bd1b2b..dcdb8667bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -168,6 +168,7 @@ All notable changes to this project will be documented in this file. The format - Change preferredUnit property to store unitType ids ([#1787](https://github.com/bloom-housing/bloom/pull/1787)) (Sean Albert) - Trying to confirm already confirmed user now throws account already confirmed error instead of tokenMissing ([#1971](https://github.com/bloom-housing/bloom/pull/1971)) - Updates CSV Builder service to work with any data set, predefined or not. ([#1955](https://github.com/bloom-housing/bloom/pull/1955)) + - Remove field applicationAddress ([#2009](https://github.com/bloom-housing/bloom/pull/2009)) (Emily Jablonski) - Introduce N-M Listing-Preference relation through a self managed (not TypeORM managed) intermediate entity ListingPreference, which now holds ordinal and page. Remove Preference entity entirely with an appropriate DB migration. ([1947](https://github.com/bloom-housing/bloom/pull/1947)) - Fixed: diff --git a/backend/core/archer.ts b/backend/core/archer.ts index 842063a4f2..5779744bec 100644 --- a/backend/core/archer.ts +++ b/backend/core/archer.ts @@ -276,17 +276,6 @@ export const ArcherListing: Listing = { whatToExpect: "Applicant will be contacted. All info will be verified. Be prepared if chosen.", status: ListingStatus.active, postmarkedApplicationsReceivedByDate: new Date("2019-12-05"), - applicationAddress: { - id: "id", - createdAt: new Date(), - updatedAt: new Date(), - city: "San Jose", - street: "98 Archer Street", - zipCode: "95112", - state: "CA", - latitude: 37.36537, - longitude: -121.91071, - }, applicationDueDate: new Date("2019-12-31T15:22:57.000-07:00"), applicationMethods: [], applicationOrganization: "98 Archer Street", diff --git a/backend/core/src/listings/dto/listing-create.dto.ts b/backend/core/src/listings/dto/listing-create.dto.ts index 0cafefbfc6..94c3f624e8 100644 --- a/backend/core/src/listings/dto/listing-create.dto.ts +++ b/backend/core/src/listings/dto/listing-create.dto.ts @@ -62,11 +62,6 @@ export class ListingCreateDto extends OmitType(ListingDto, [ @Type(() => ApplicationMethodCreateDto) applicationMethods: ApplicationMethodCreateDto[] - @Expose() - @IsOptional({ groups: [ValidationsGroupsEnum.default] }) - @Type(() => AddressCreateDto) - applicationAddress?: AddressCreateDto | null - @Expose() @IsOptional({ groups: [ValidationsGroupsEnum.default] }) @Type(() => AddressCreateDto) diff --git a/backend/core/src/listings/dto/listing-update.dto.ts b/backend/core/src/listings/dto/listing-update.dto.ts index e6f9318bcb..2e7a5a481f 100644 --- a/backend/core/src/listings/dto/listing-update.dto.ts +++ b/backend/core/src/listings/dto/listing-update.dto.ts @@ -81,11 +81,6 @@ export class ListingUpdateDto extends OmitType(ListingDto, [ @Type(() => ApplicationMethodUpdateDto) applicationMethods: ApplicationMethodUpdateDto[] - @Expose() - @IsOptional({ groups: [ValidationsGroupsEnum.default] }) - @Type(() => AddressUpdateDto) - applicationAddress?: AddressUpdateDto | null - @Expose() @IsOptional({ groups: [ValidationsGroupsEnum.default] }) @Type(() => AddressUpdateDto) diff --git a/backend/core/src/listings/dto/listing.dto.ts b/backend/core/src/listings/dto/listing.dto.ts index 2062300c67..270591276b 100644 --- a/backend/core/src/listings/dto/listing.dto.ts +++ b/backend/core/src/listings/dto/listing.dto.ts @@ -19,7 +19,6 @@ import { ListingPreferenceDto } from "../../preferences/dto/listing-preference.d import { ListingProgramDto } from "../../program/dto/listing-program.dto" export class ListingDto extends OmitType(Listing, [ - "applicationAddress", "applicationPickUpAddress", "applicationDropOffAddress", "applicationMailingAddress", @@ -44,12 +43,6 @@ export class ListingDto extends OmitType(Listing, [ @Type(() => ApplicationMethodDto) applicationMethods: ApplicationMethodDto[] - @Expose() - @IsOptional({ groups: [ValidationsGroupsEnum.default] }) - @ValidateNested({ groups: [ValidationsGroupsEnum.default] }) - @Type(() => AddressDto) - applicationAddress?: AddressDto | null - @Expose() @IsOptional({ groups: [ValidationsGroupsEnum.default] }) @ValidateNested({ groups: [ValidationsGroupsEnum.default] }) diff --git a/backend/core/src/listings/entities/listing.entity.ts b/backend/core/src/listings/entities/listing.entity.ts index 21803bbb81..ecc683f540 100644 --- a/backend/core/src/listings/entities/listing.entity.ts +++ b/backend/core/src/listings/entities/listing.entity.ts @@ -181,13 +181,6 @@ class Listing extends BaseEntity { @IsString({ groups: [ValidationsGroupsEnum.default] }) applicationOrganization?: string | null - @ManyToOne(() => Address, { eager: true, nullable: true, cascade: true }) - @Expose() - @IsOptional({ groups: [ValidationsGroupsEnum.default] }) - @ValidateNested({ groups: [ValidationsGroupsEnum.default] }) - @Type(() => Address) - applicationAddress?: Address | null - @ManyToOne(() => Address, { eager: true, nullable: true, cascade: true }) @Expose() @IsOptional({ groups: [ValidationsGroupsEnum.default] }) diff --git a/backend/core/src/listings/listings.module.ts b/backend/core/src/listings/listings.module.ts index 9be7012c88..60656bd4fb 100644 --- a/backend/core/src/listings/listings.module.ts +++ b/backend/core/src/listings/listings.module.ts @@ -68,6 +68,7 @@ export class ListingsModule implements OnApplicationShutdown, OnModuleInit { } onApplicationShutdown() { console.log("Disconnect from Redis") + void this.cacheManager.store.reset() this.redisClient.quit() } diff --git a/backend/core/src/listings/views/config.ts b/backend/core/src/listings/views/config.ts index 2451b535f5..3fe635c3a2 100644 --- a/backend/core/src/listings/views/config.ts +++ b/backend/core/src/listings/views/config.ts @@ -147,7 +147,6 @@ views.detail = { "result.fileId", "result.label", ...getBaseAddressSelect([ - "applicationAddress", "leasingAgentAddress", "applicationPickUpAddress", "applicationMailingAddress", @@ -171,7 +170,6 @@ views.detail = { { join: "listings.events", alias: "listingEvents" }, { join: "listingEvents.file", alias: "listingEventFile" }, { join: "listings.result", alias: "result" }, - { join: "listings.applicationAddress", alias: "applicationAddress" }, { join: "listings.leasingAgentAddress", alias: "leasingAgentAddress" }, { join: "listings.applicationPickUpAddress", alias: "applicationPickUpAddress" }, { join: "listings.applicationMailingAddress", alias: "applicationMailingAddress" }, @@ -190,7 +188,6 @@ views.full = { ["listings.events", "listingEvents"], ["listingEvents.file", "listingEventFile"], ["listings.result", "result"], - ["listings.applicationAddress", "applicationAddress"], ["listings.leasingAgentAddress", "leasingAgentAddress"], ["listings.applicationPickUpAddress", "applicationPickUpAddress"], ["listings.applicationMailingAddress", "applicationMailingAddress"], diff --git a/backend/core/src/migration/1634316081536-remove-app-address.ts b/backend/core/src/migration/1634316081536-remove-app-address.ts new file mode 100644 index 0000000000..8327e637e6 --- /dev/null +++ b/backend/core/src/migration/1634316081536-remove-app-address.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from "typeorm" + +export class removeAppAddress1634316081536 implements MigrationInterface { + name = "removeAppAddress1634316081536" + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "listings" DROP CONSTRAINT "FK_42385e47be1780d1491f0c8c1c3"` + ) + await queryRunner.query(`ALTER TABLE "listings" DROP COLUMN "application_address_id"`) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "listings" ADD "application_address_id" uuid`) + await queryRunner.query( + `ALTER TABLE "listings" ADD CONSTRAINT "FK_42385e47be1780d1491f0c8c1c3" FOREIGN KEY ("application_address_id") REFERENCES "address"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } +} diff --git a/backend/core/src/seeds/listings/listing-coliseum-seed.ts b/backend/core/src/seeds/listings/listing-coliseum-seed.ts index e1bdba837b..a23075da83 100644 --- a/backend/core/src/seeds/listings/listing-coliseum-seed.ts +++ b/backend/core/src/seeds/listings/listing-coliseum-seed.ts @@ -877,15 +877,6 @@ const coliseumUnits: Array = [ const coliseumListing: ListingSeedType = { jurisdictionName: "Alameda", - applicationAddress: { - county: "Alameda", - city: "Oakland", - street: "1701 Martin Luther King Way", - zipCode: "94621", - state: "CA", - latitude: 37.7549632, - longitude: -122.1968792, - }, digitalApplication: false, commonDigitalApplication: false, paperApplication: false, diff --git a/backend/core/src/seeds/listings/listing-triton-seed.ts b/backend/core/src/seeds/listings/listing-triton-seed.ts index c6e5829ead..def28f3ea4 100644 --- a/backend/core/src/seeds/listings/listing-triton-seed.ts +++ b/backend/core/src/seeds/listings/listing-triton-seed.ts @@ -685,14 +685,6 @@ const tritonUnits: Array = [ const tritonListing: ListingSeedType = { jurisdictionName: "Alameda", - applicationAddress: { - city: "Foster City", - state: "CA", - street: "55 Triton Park Lane", - zipCode: "94404", - latitude: 37.5658152, - longitude: -122.2704286, - }, digitalApplication: false, commonDigitalApplication: false, paperApplication: false, diff --git a/backend/core/src/seeds/listings/shared.ts b/backend/core/src/seeds/listings/shared.ts index 004babed3d..348ebf8126 100644 --- a/backend/core/src/seeds/listings/shared.ts +++ b/backend/core/src/seeds/listings/shared.ts @@ -462,15 +462,6 @@ export function getDefaultListing() { export const defaultListing: ListingSeedType = { jurisdictionName: "Alameda", - applicationAddress: { - city: "San Francisco", - state: "CA", - street: "548 Market Street", - street2: "Suite #59930", - zipCode: "94104", - latitude: 37.789673, - longitude: -122.40151, - }, countyCode: CountyCode.alameda, applicationDropOffAddress: null, applicationDropOffAddressOfficeHours: null, diff --git a/backend/core/test/factories/listing.ts b/backend/core/test/factories/listing.ts index e37ebf184d..c47a2a949f 100644 --- a/backend/core/test/factories/listing.ts +++ b/backend/core/test/factories/listing.ts @@ -16,15 +16,6 @@ export default Factory.define(({ sequence, factories }) => ({ applicationOpenDate: null, applicationFee: "30.0", applicationOrganization: `Triton-${sequence}`, - applicationAddress: { - city: `Foster City-${sequence}`, - street: "55 Triton Park Lane", - zipCode: "94404", - state: "CA", - county: "San Jose", - latitude: 37.55695, - longitude: -122.27521, - }, blankPaperApplicationCanBePickedUp: true, buildingAddress: { city: `Foster City-${sequence}`, diff --git a/backend/core/test/listings/listings.e2e-spec.ts b/backend/core/test/listings/listings.e2e-spec.ts index 3637e52f9e..f8a8640dbf 100644 --- a/backend/core/test/listings/listings.e2e-spec.ts +++ b/backend/core/test/listings/listings.e2e-spec.ts @@ -94,7 +94,7 @@ describe("Listings", () => { // TODO: replace jsonpath with SQL-level filtering it("should return only the specified listings", async () => { const query = - "/?limit=all&jsonpath=%24%5B%3F%28%40.applicationAddress.city%3D%3D%22Foster%20City%22%29%5D" + "/?limit=all&jsonpath=%24%5B%3F%28%40.buildingAddress.city%3D%3D%22Foster%20City%22%29%5D" const res = await supertest(app.getHttpServer()).get(`/listings${query}`).expect(200) expect(res.body.items.length).toEqual(2) for (const item of res.body.items) { diff --git a/backend/core/types/src/archer-listing.ts b/backend/core/types/src/archer-listing.ts index d8b9073a2e..3e856af5b0 100644 --- a/backend/core/types/src/archer-listing.ts +++ b/backend/core/types/src/archer-listing.ts @@ -599,17 +599,6 @@ export const ArcherListing: Listing = { events: [], urlSlug: "listing-slug-abcdef", status: ListingStatus.active, - applicationAddress: { - id: "id", - createdAt: new Date(), - updatedAt: new Date(), - city: "San Jose", - street: "98 Archer Street", - zipCode: "95112", - state: "CA", - latitude: 37.36537, - longitude: -121.91071, - }, applicationDueDate: new Date("2019-12-31T15:22:57.000-07:00"), applicationMethods: [], applicationOrganization: "98 Archer Street", diff --git a/backend/core/types/src/backend-swagger.ts b/backend/core/types/src/backend-swagger.ts index 19692a82e2..4bc96ea8aa 100644 --- a/backend/core/types/src/backend-swagger.ts +++ b/backend/core/types/src/backend-swagger.ts @@ -4728,9 +4728,6 @@ export interface Listing { /** */ applicationMethods: ApplicationMethod[] - /** */ - applicationAddress?: CombinedApplicationAddressTypes - /** */ applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes @@ -5146,9 +5143,6 @@ export interface ListingCreate { /** */ applicationMethods: ApplicationMethodCreate[] - /** */ - applicationAddress?: CombinedApplicationAddressTypes - /** */ applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes @@ -5567,9 +5561,6 @@ export interface ListingUpdate { /** */ applicationMethods: ApplicationMethodUpdate[] - /** */ - applicationAddress?: CombinedApplicationAddressTypes - /** */ applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes @@ -6314,7 +6305,6 @@ export enum UnitStatus { "unavailable" = "unavailable", } export type CombinedPriorityTypeTypes = UnitAccessibilityPriorityType -export type CombinedApplicationAddressTypes = AddressUpdate export type CombinedApplicationPickUpAddressTypes = AddressUpdate export type CombinedApplicationDropOffAddressTypes = AddressUpdate export type CombinedApplicationMailingAddressTypes = AddressUpdate diff --git a/sites/partners/src/listings/PaperListingForm/index.tsx b/sites/partners/src/listings/PaperListingForm/index.tsx index 5fde7a7911..306fb21615 100644 --- a/sites/partners/src/listings/PaperListingForm/index.tsx +++ b/sites/partners/src/listings/PaperListingForm/index.tsx @@ -134,7 +134,6 @@ const defaults: FormListing = { id: undefined, createdAt: undefined, updatedAt: undefined, - applicationAddress: null, applicationDueDate: null, applicationDueTime: null, applicationFee: null, diff --git a/sites/public/cypress/fixtures/listing.json b/sites/public/cypress/fixtures/listing.json index 94f2bd3773..f19002c218 100644 --- a/sites/public/cypress/fixtures/listing.json +++ b/sites/public/cypress/fixtures/listing.json @@ -8,14 +8,6 @@ "applicationOpenDate": null, "applicationFee": "30.0", "applicationOrganization": "98 Archer Street", - "applicationAddress": { - "city": "San Jose", - "state": "CA", - "street": "98 Archer Street", - "zipCode": "95112", - "latitude": 37.36537, - "longitude": -121.91071 - }, "blankPaperApplicationCanBePickedUp": true, "buildingAddress": { "city": "San Jose", diff --git a/ui-components/__tests__/fixtures/archer.json b/ui-components/__tests__/fixtures/archer.json index 1463294035..7ac042927b 100644 --- a/ui-components/__tests__/fixtures/archer.json +++ b/ui-components/__tests__/fixtures/archer.json @@ -3,14 +3,6 @@ "postmarkedApplicationsReceivedByDate": "2019-12-05", "accessibility": "There is a total of 5 ADA units in the complex, all others are adaptable. Exterior Wheelchair ramp (front entry)", "amenities": "Community Room, Laundry Room, Assigned Parking, Bike Storage, Roof Top Garden, Part-time Resident Service Coordinator", - "applicationAddress": { - "city": "San Jose", - "street": "98 Archer Street", - "zipCode": "95112", - "state": "CA", - "latitude": 37.36537, - "longitude": -121.91071 - }, "applicationDueDate": "2019-12-31T15:22:57.000-07:00", "applicationMethods": [], "applicationOrganization": "98 Archer Street", diff --git a/ui-components/__tests__/fixtures/gish.json b/ui-components/__tests__/fixtures/gish.json index 0a29824d3d..2135dfee80 100644 --- a/ui-components/__tests__/fixtures/gish.json +++ b/ui-components/__tests__/fixtures/gish.json @@ -4,14 +4,6 @@ "acceptingOnlineApplications": false, "accessibility": "Accessibility features in common areas like lobby – wheelchair ramps, wheelchair accessible bathrooms and elevators.", "amenities": "Community Room, Laundry", - "applicationAddress": { - "city": "San Jose", - "street": "35 East Gish Road", - "zipCode": "95112", - "state": "CA", - "latitude": 37.36219, - "longitude": -121.909447 - }, "applicationDueDate": "2019-12-09T12:58:21.000-07:00", "applicationOrganization": "35 East Gish Road", "applicationPhone": "(408) 436-8972", diff --git a/ui-components/__tests__/fixtures/triton-test.json b/ui-components/__tests__/fixtures/triton-test.json index 401b7a8c28..17c30a2ae3 100644 --- a/ui-components/__tests__/fixtures/triton-test.json +++ b/ui-components/__tests__/fixtures/triton-test.json @@ -4,14 +4,6 @@ "acceptingOnlineApplications": true, "accessibility": "Accessibility features in common areas like lobby – wheelchair ramps, wheelchair accessible bathrooms and elevators.", "amenities": "Gym, Clubhouse, Business Lounge, View Lounge, Pool, Spa", - "applicationAddress": { - "city": "Foster City", - "street": "55 Triton Park Lane", - "zipCode": "94404", - "state": "CA", - "latitude": 37.55695, - "longitude": -122.27521 - }, "applicationDueDate": "2037-12-19T17:00:00.000-07:00", "applicationOrganization": "Triton", "applicationPhone": "(650) 437-2039", diff --git a/ui-components/__tests__/page_components/SidebarAddress.test.tsx b/ui-components/__tests__/page_components/SidebarAddress.test.tsx index 12d2c5eb25..e7af138f22 100644 --- a/ui-components/__tests__/page_components/SidebarAddress.test.tsx +++ b/ui-components/__tests__/page_components/SidebarAddress.test.tsx @@ -7,8 +7,8 @@ afterEach(cleanup) describe("", () => { it("renders with address", () => { - const { getByText } = render() - expect(getByText(ArcherListing.applicationAddress?.street || "", { exact: false })).toBeTruthy() + const { getByText } = render() + expect(getByText(ArcherListing.buildingAddress?.street || "", { exact: false })).toBeTruthy() expect(getByText("Get Directions")).toBeTruthy() }) it("renders with office hours and no address", () => {