Skip to content

Commit

Permalink
refactor: remove applicationAddress (#2009)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Michal Plebanski <[email protected]>
Co-authored-by: Sean Albert <[email protected]>
  • Loading branch information
4 people authored Nov 12, 2021
1 parent 2b83bc0 commit bf10632
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 130 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 0 additions & 11 deletions backend/core/archer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 0 additions & 5 deletions backend/core/src/listings/dto/listing-create.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions backend/core/src/listings/dto/listing-update.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions backend/core/src/listings/dto/listing.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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] })
Expand Down
7 changes: 0 additions & 7 deletions backend/core/src/listings/entities/listing.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] })
Expand Down
1 change: 1 addition & 0 deletions backend/core/src/listings/listings.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class ListingsModule implements OnApplicationShutdown, OnModuleInit {
}
onApplicationShutdown() {
console.log("Disconnect from Redis")
void this.cacheManager.store.reset()
this.redisClient.quit()
}

Expand Down
3 changes: 0 additions & 3 deletions backend/core/src/listings/views/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ views.detail = {
"result.fileId",
"result.label",
...getBaseAddressSelect([
"applicationAddress",
"leasingAgentAddress",
"applicationPickUpAddress",
"applicationMailingAddress",
Expand All @@ -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" },
Expand All @@ -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"],
Expand Down
19 changes: 19 additions & 0 deletions backend/core/src/migration/1634316081536-remove-app-address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class removeAppAddress1634316081536 implements MigrationInterface {
name = "removeAppAddress1634316081536"

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`
)
}
}
9 changes: 0 additions & 9 deletions backend/core/src/seeds/listings/listing-coliseum-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,15 +877,6 @@ const coliseumUnits: Array<UnitSeedType> = [

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,
Expand Down
8 changes: 0 additions & 8 deletions backend/core/src/seeds/listings/listing-triton-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,6 @@ const tritonUnits: Array<UnitSeedType> = [

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,
Expand Down
9 changes: 0 additions & 9 deletions backend/core/src/seeds/listings/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions backend/core/test/factories/listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ export default Factory.define<Listing>(({ 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}`,
Expand Down
2 changes: 1 addition & 1 deletion backend/core/test/listings/listings.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions backend/core/types/src/archer-listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 0 additions & 10 deletions backend/core/types/src/backend-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4728,9 +4728,6 @@ export interface Listing {
/** */
applicationMethods: ApplicationMethod[]

/** */
applicationAddress?: CombinedApplicationAddressTypes

/** */
applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes

Expand Down Expand Up @@ -5146,9 +5143,6 @@ export interface ListingCreate {
/** */
applicationMethods: ApplicationMethodCreate[]

/** */
applicationAddress?: CombinedApplicationAddressTypes

/** */
applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes

Expand Down Expand Up @@ -5567,9 +5561,6 @@ export interface ListingUpdate {
/** */
applicationMethods: ApplicationMethodUpdate[]

/** */
applicationAddress?: CombinedApplicationAddressTypes

/** */
applicationPickUpAddress?: CombinedApplicationPickUpAddressTypes

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion sites/partners/src/listings/PaperListingForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const defaults: FormListing = {
id: undefined,
createdAt: undefined,
updatedAt: undefined,
applicationAddress: null,
applicationDueDate: null,
applicationDueTime: null,
applicationFee: null,
Expand Down
8 changes: 0 additions & 8 deletions sites/public/cypress/fixtures/listing.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 0 additions & 8 deletions ui-components/__tests__/fixtures/archer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 0 additions & 8 deletions ui-components/__tests__/fixtures/gish.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 0 additions & 8 deletions ui-components/__tests__/fixtures/triton-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ afterEach(cleanup)

describe("<SidebarAddress>", () => {
it("renders with address", () => {
const { getByText } = render(<SidebarAddress address={ArcherListing.applicationAddress} />)
expect(getByText(ArcherListing.applicationAddress?.street || "", { exact: false })).toBeTruthy()
const { getByText } = render(<SidebarAddress address={ArcherListing.buildingAddress} />)
expect(getByText(ArcherListing.buildingAddress?.street || "", { exact: false })).toBeTruthy()
expect(getByText("Get Directions")).toBeTruthy()
})
it("renders with office hours and no address", () => {
Expand Down

0 comments on commit bf10632

Please sign in to comment.