Skip to content

Commit

Permalink
Dev (#1701)
Browse files Browse the repository at this point in the history
* 1545/lat-long draggable map (#1577)

* 1616/user roles (#1673) from 1628

* User roles for partners

* generate migration

* update client

* update seeds and policy

* migrate partners from leasing agent table

* change enum name

* Remove anonymous role

* Update authz.service.ts

* fix application view

* update changelog

* fix backend tests

* add test

* fix ui tests

Co-authored-by: Abbie Farr <afarr@google.com>
Co-authored-by: Abbie Farr <83078310+abbiefarr@users.noreply.github.com>

* Fix code style issues with Prettier

* 1587/Updates Listing Columns and Perms so Leasing Agents can Edit (#1627)

* updates for cache revalidation on the frontend

* fixes listing bug issue

* Updates partner listings columns

* updates policy and user perms

* skips tests until #1616 is implemented

* updates to work with new user roles

* remove origin from listing service list args

* test update

* Fix code style issues with Prettier

* Split Listing form up into two main tabs (#1644)

* Add tabs to the listing form

* Fix button positions and ensure tabs always render

* Add #1644 to Changelog

* fixes warning for ArrowForward props

Co-authored-by: seanmalbert <smabert@gmail.com>

* Contribute Feature/Ensure Progress Bar is screen reader friendly (#1674)

* Add unit size filter to backend (#1660)

* Add unit size filter to backend (#368)

* initial thoughts

* initial bedrooms filter (untested)

* Fix code style issues with Prettier

* fix typo in 'studio'

* remove custom filter handling, switch to bedrooms field on unit table

* add additional check for invalid comparisons, outside the filter handler

* use unit_type table for bedrooms, add field to unit_type table, remove toLowerCase() from filter name comparisons to allow camelCase filter names

* Fix code style issues with Prettier

* add bedrooms filter to frontend comparison map

* fix comparison type for frontend map

* fix test and migration indentation

* update changelog

* regenerate swagger

* fix tests

* try to fix more ui tests

* try to fix more ui tests

* add comment for custom filter handling

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* fix missing bedrooms build error

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* 1431/google translate (#1590)

* Initial google translate listing

* Translations for arrays

* Disable caching for GET listing endpoint

* Final tweaks to google translate

* Update change log for google translations

* Fix code style issues with Prettier

* Update CHANGELOG.md

* Minor cleanup for Google Translate

* Initial google translate listing

* Translations for arrays

* Disable caching for GET listing endpoint

* Final tweaks to google translate

* Update change log for google translations

* Fix code style issues with Prettier

* Update CHANGELOG.md

* Minor cleanup for Google Translate

* Google translate refactoring

* Fix listings service spec

* adds custom cache interceptor for language

* updates custom cache interceptor

* Add missing Headers import for listings controller

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
Co-authored-by: seanmalbert <smabert@gmail.com>

* Restructure units summary table (#1670)

* Add UnitsSummary to Listing

* remove listing service changes

* redo migration

* monthlyRent as number

* fix lint errors

* Fix code style issues with Prettier

* Hardcode the number of items in listings.e2e-spec.ts. (#1643)

Using the length of the array from seed.ts was causing flakiness if the
bloom database was not set up in the testing environment.

Co-authored-by: seanmalbert <smabert@gmail.com>

* Contribute/Create listing updated UI component (#1676)

* 1621/Listing Views (#1626)

* set fallback to true for getStaticPaths so new paths can be added

* adds revalidate to staticProps

* updates for cache revalidation on the frontend

* trigger cleanup

* fixes listing bug issue

* adds additional checks for unit type and priority

* new line

* Fix code style issues with Prettier

* adds listing view

* adds other views

* adds unitsAvailable to select

* updates to pass view as query param for list and by id

* removes comment

* Update CHANGELOG.md

* updates view test

* rename spec and remove log

* removes another log

* updates partner-role migration

* updates partner-role migration

* adds --runInBand --detectOpenHandles to backend test

* adds view param to applications e2e spec test that fetches listings

* updates default view to full and fixes housing-counselors bug

* view test update

Co-authored-by: Lint Action <lint-action@samuelmeuli.com>

* 1629/fcfs with date (#1680)

* 1629/fcfs with date

* changelog

* 1611/what to expect editable in listings management (#1681)

* 1611/what to expect editable

* fixup unit test

* changelog

* Make actions an optional prop and hide the footer when not present. (#1690)

* Make features section more robust (#1688)

* Fixes whatToExpect UI Component failing test (#1692)

* force quit redis connection on app close

* updates for redis config

* adds enableShutdownHooks to main app

* Update archer-listing.ts

* Add migration (#1689)

Co-authored-by: seanmalbert <smabert@gmail.com>

* Fix code style issues with Prettier

* adds SRO to num_bedroom case

* 872/allow for unit sets to have multiple ami charts (#1678)

* Updates cache clear to use reset, instead of maintaining cache keys (#1698)

* force quit redis connection on app close

* updates for redis config

* adds enableShutdownHooks to main app

* Update archer-listing.ts

* Updates cache clear to use cacheManager reset, so we don't have to maintain keys

* Update units-transformations.ts

* Update CHANGELOG.md

* allows for not needing google api keys

* Update listings.controller.ts

* Update listings.e2e-spec.ts

* testing build issues (#1699)

* testing build issues

* testing build issues pt 2

* Updates translations to check for values before sending to service

Co-authored-by: seanmalbert <smabert@gmail.com>

Co-authored-by: Emily Jablonski <65367387+emilyjablonski@users.noreply.github.com>
Co-authored-by: Abbie Farr <afarr@google.com>
Co-authored-by: Abbie Farr <83078310+abbiefarr@users.noreply.github.com>
Co-authored-by: Lint Action <lint-action@samuelmeuli.com>
Co-authored-by: Jared White <jared@jaredwhite.com>
Co-authored-by: pfeeny5 <82653098+pfeeny5@users.noreply.github.com>
Co-authored-by: Austin Valeske <avaleske@users.noreply.github.com>
Co-authored-by: Marcin Jędras <mjjedras@gmail.com>
Co-authored-by: Will Lin <4317058+willrlin@users.noreply.github.com>
Co-authored-by: Anders Schneider <anderseschneider@gmail.com>
  • Loading branch information
11 people authored Aug 20, 2021
1 parent 96a5803 commit e041609
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 99 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ All notable changes to this project will be documented in this file. The format
- Updates redis reset call to flush all keys
- Updated listing's importer to handle latest reserved community type changes ([#1667](https://github.com/bloom-housing/bloom/pull/1667)) (Emily Jablonski)
- Change whatToExpect to be a string instead of a json blob, make it editable in listings management ([#1681](https://github.com/bloom-housing/bloom/pull/1681)) (Emily Jablonski)
- Updates listing post/put/delete endpoints to call cacheManager.reset instead of clearing and maintaining a growing set of keys. Updates transformUnits to check for units and length before continuing ([#1698](https://github.com/bloom-housing/bloom/pull/1698))
- Allow for unit sets to have multiple ami charts ([#1678](https://github.com/bloom-housing/bloom/pull/1678)) (Emily Jablonski)

- Fixed:
- Added checks for property in listing.dto transforms
- Display all listings on partners with `limit=all` ([#1635](https://github.com/bloom-housing/bloom/issues/1635)) (Marcin Jędras)
- Seed data should create unique application methods ([#1662](https://github.com/bloom-housing/bloom/issues/1662)) (Emily Jablonski)
- fixes issue with unexposed user roles ((#1627)[https://github.com/bloom-housing/bloom/pull/1627]))
- updates translations to check for values before sending to service ((#1699)[https://github.com/bloom-housing/bloom/pull/1699])

### General

Expand Down
15 changes: 15 additions & 0 deletions backend/core/src/libs/miscLib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Determines if object is an empty array, empty object, undefined, null or an
* empty string.
*/
export function isEmpty(obj: unknown): boolean {
return (
obj === undefined ||
obj === null ||
(obj instanceof Array && obj.length === 0) ||
(obj instanceof Object &&
Object.getPrototypeOf(obj) === Object.prototype &&
Object.keys(obj).length === 0) ||
obj === ""
)
}
26 changes: 4 additions & 22 deletions backend/core/src/listings/listings.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { OptionalAuthGuard } from "../auth/guards/optional-auth.guard"
import { AuthzGuard } from "../auth/guards/authz.guard"
import { mapTo } from "../shared/mapTo"
import { defaultValidationPipeOptions } from "../shared/default-validation-pipe-options"
import { clearCacheKeys } from "../libs/cacheLib"
import { Language } from "../shared/types/language-enum"
import { ListingLangCacheInterceptor } from "../cache/listing-lang-cache.interceptor"

Expand All @@ -48,15 +47,7 @@ export class ListingsController {
constructor(
@Inject(CACHE_MANAGER) private cacheManager: Cache,
private readonly listingsService: ListingsService
) {
this.cacheKeys = [
"/listings",
"/listings?limit=all",
"/listings?view=base&limit=all",
"/listings?limit=all&filter[$comparison]=%3C%3E&filter[status]=pending",
"/listings?view=base&limit=all&filter[$comparison]=%3C%3E&filter[status]=pending",
]
}
) {}

// TODO: Limit requests to defined fields
@Get()
Expand All @@ -72,11 +63,7 @@ export class ListingsController {
@ApiOperation({ summary: "Create listing", operationId: "create" })
async create(@Body() listingDto: ListingCreateDto): Promise<ListingDto> {
const listing = await this.listingsService.create(listingDto)
/**
* clear list caches
* As we get more listings we'll want to update this to be more selective in clearing entries
*/
await clearCacheKeys(this.cacheManager, this.cacheKeys)
await this.cacheManager.reset()
return mapTo(ListingDto, listing)
}

Expand All @@ -88,7 +75,6 @@ export class ListingsController {
@Param("listingId") listingId: string,
@Query("view") view?: string
): Promise<ListingDto> {
console.log("controller view = ", view)
if (listingId === undefined || listingId === "undefined") {
return mapTo(ListingDto, {})
}
Expand All @@ -102,18 +88,14 @@ export class ListingsController {
@Body() listingUpdateDto: ListingUpdateDto
): Promise<ListingDto> {
const listing = await this.listingsService.update(listingUpdateDto)
/**
* clear list caches
* As we get more listings we'll want to update this to be more selective in clearing entries
*/
await clearCacheKeys(this.cacheManager, [...this.cacheKeys, `/listings/${listingId}`])
await this.cacheManager.reset()
return mapTo(ListingDto, listing)
}

@Delete(`:listingId`)
@ApiOperation({ summary: "Delete listing by id", operationId: "delete" })
async delete(@Param("listingId") listingId: string) {
await this.listingsService.delete(listingId)
await clearCacheKeys(this.cacheManager, [...this.cacheKeys, `/listings/${listingId}`])
await this.cacheManager.reset()
}
}
4 changes: 4 additions & 0 deletions backend/core/src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { AuthContext } from "./auth/types/auth-context"
import { ListingDefaultReservedSeed } from "./seeds/listings/listing-default-reserved-seed"
import { ListingDefaultFCFSSeed } from "./seeds/listings/listing-default-fcfs-seed"
import { UserRoles } from "./auth/entities/user-roles.entity"
import { ListingDefaultMultipleAMI } from "./seeds/listings/listing-default-multiple-ami"
import { ListingDefaultMultipleAMIAndPercentages } from "./seeds/listings/listing-default-multiple-ami-and-percentages"

const argv = yargs.scriptName("seed").options({
test: { type: "boolean", default: false },
Expand All @@ -43,6 +45,8 @@ const listingSeeds: any[] = [
ListingTritonSeed,
ListingDefaultReservedSeed,
ListingDefaultFCFSSeed,
ListingDefaultMultipleAMI,
ListingDefaultMultipleAMIAndPercentages,
]

export function getSeedListingsCount() {
Expand Down
4 changes: 4 additions & 0 deletions backend/core/src/seeder/seeder.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { ApplicationMethodsModule } from "../application-methods/applications-me
import { PaperApplicationsModule } from "../paper-applications/paper-applications.module"
import { AssetsModule } from "../assets/assets.module"
import { ListingDefaultReservedSeed } from "../seeds/listings/listing-default-reserved-seed"
import { ListingDefaultMultipleAMI } from "../seeds/listings/listing-default-multiple-ami"
import { ListingDefaultMultipleAMIAndPercentages } from "../seeds/listings/listing-default-multiple-ami-and-percentages"

@Module({})
export class SeederModule {
Expand Down Expand Up @@ -85,6 +87,8 @@ export class SeederModule {
ListingTritonSeed,
ListingDefaultReservedSeed,
ListingDefaultFCFSSeed,
ListingDefaultMultipleAMI,
ListingDefaultMultipleAMIAndPercentages,
],
}
}
Expand Down
39 changes: 34 additions & 5 deletions backend/core/src/seeds/listings/listing-default-bmr-chart-seed.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultUnits } from "./shared"
import { getDefaultUnits, getDefaultProperty, getDefaultAmiChart } from "./shared"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"

export class ListingDefaultBmrChartSeed extends ListingDefaultSeed {
async seed() {
const listing = await super.seed()
const defaultUnits = getDefaultUnits()

const unitTypeOneBdrm = await this.unitTypeRepository.findOneOrFail({ name: "oneBdrm" })
const unitTypeTwoBdrm = await this.unitTypeRepository.findOneOrFail({ name: "twoBdrm" })

const amiChart = await this.amiChartRepository.save(getDefaultAmiChart())

const property = await this.propertyRepository.save({
...getDefaultProperty(),
})

const bmrUnits = [
{ ...defaultUnits[0], bmrProgramChart: true, monthlyIncomeMin: "700", monthlyRent: "350" },
{ ...defaultUnits[1], bmrProgramChart: true, monthlyIncomeMin: "800", monthlyRent: "400" },
]

const unitsToBeCreated: Array<Omit<UnitCreateDto, keyof BaseEntity>> = bmrUnits.map((unit) => {
return {
...unit,
property: {
id: property.id,
},
amiChart,
}
})

unitsToBeCreated[0].unitType = unitTypeOneBdrm
unitsToBeCreated[1].unitType = unitTypeTwoBdrm

await this.unitsRepository.save(unitsToBeCreated)

return await this.listingRepository.save({
...listing,
name: "Test: Default, BMR Chart",
preferences: [],
units: [
{ ...defaultUnits[0], bmrProgramChart: true, monthlyIncomeMin: "700", monthlyRent: "350" },
{ ...defaultUnits[1], bmrProgramChart: true, monthlyIncomeMin: "800", monthlyRent: "400" },
],
property,
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultAmiChart, getDefaultProperty } from "./shared"
import { tritonAmiChart } from "./listing-triton-seed"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"
import { UnitSeedType } from "./listings"
import { UnitStatus } from "../../units/types/unit-status-enum"

export class ListingDefaultMultipleAMIAndPercentages extends ListingDefaultSeed {
async seed() {
const listing = await super.seed()

const unitTypeOneBdrm = await this.unitTypeRepository.findOneOrFail({ name: "oneBdrm" })

const amiChartOne = await this.amiChartRepository.save(tritonAmiChart)
const amiChartTwo = await this.amiChartRepository.save(getDefaultAmiChart())

const property = await this.propertyRepository.save({
...getDefaultProperty(),
})

const multipleAMIUnits: Array<UnitSeedType> = [
{
amiChart: amiChartOne,
amiPercentage: "30",
annualIncomeMax: "45600",
annualIncomeMin: "36168",
bmrProgramChart: false,
floor: 1,
maxOccupancy: 3,
minOccupancy: 1,
monthlyIncomeMin: "3014",
monthlyRent: "1219",
monthlyRentAsPercentOfIncome: null,
numBathrooms: 1,
numBedrooms: 1,
number: null,
sqFeet: "635",
status: UnitStatus.available,
},
{
amiChart: amiChartTwo,
amiPercentage: "30",
annualIncomeMax: "45600",
annualIncomeMin: "36168",
bmrProgramChart: false,
floor: 1,
maxOccupancy: 3,
minOccupancy: 1,
monthlyIncomeMin: "3014",
monthlyRent: "1219",
monthlyRentAsPercentOfIncome: null,
numBathrooms: 1,
numBedrooms: 1,
number: null,
sqFeet: "635",
status: UnitStatus.available,
},
{
amiChart: amiChartOne,
amiPercentage: "50",
annualIncomeMax: "66600",
annualIncomeMin: "41616",
bmrProgramChart: false,
floor: 2,
maxOccupancy: 5,
minOccupancy: 2,
monthlyIncomeMin: "3468",
monthlyRent: "1387",
monthlyRentAsPercentOfIncome: null,
numBathrooms: 1,
numBedrooms: 2,
number: null,
sqFeet: "748",
status: UnitStatus.available,
},
{
amiChart: amiChartTwo,
amiPercentage: "50",
annualIncomeMax: "66600",
annualIncomeMin: "41616",
bmrProgramChart: false,
floor: 2,
maxOccupancy: 5,
minOccupancy: 2,
monthlyIncomeMin: "3468",
monthlyRent: "1387",
monthlyRentAsPercentOfIncome: null,
numBathrooms: 1,
numBedrooms: 2,
number: null,
sqFeet: "748",
status: UnitStatus.available,
},
]

const unitsToBeCreated: Array<Omit<UnitCreateDto, keyof BaseEntity>> = multipleAMIUnits.map(
(unit) => {
return {
...unit,
property: {
id: property.id,
},
}
}
)

unitsToBeCreated[0].unitType = unitTypeOneBdrm
unitsToBeCreated[1].unitType = unitTypeOneBdrm
unitsToBeCreated[2].unitType = unitTypeOneBdrm
unitsToBeCreated[3].unitType = unitTypeOneBdrm

await this.unitsRepository.save(unitsToBeCreated)

return await this.listingRepository.save({
...listing,
property: property,
name: "Test: Default, Multiple AMI and Percentages",
})
}
}
43 changes: 43 additions & 0 deletions backend/core/src/seeds/listings/listing-default-multiple-ami.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ListingDefaultSeed } from "./listing-default-seed"
import { getDefaultAmiChart, getDefaultUnits, getDefaultProperty } from "./shared"
import { tritonAmiChart } from "./listing-triton-seed"
import { UnitCreateDto } from "../../units/dto/unit.dto"
import { BaseEntity } from "typeorm"

export class ListingDefaultMultipleAMI extends ListingDefaultSeed {
async seed() {
const listing = await super.seed()

const unitTypeOneBdrm = await this.unitTypeRepository.findOneOrFail({ name: "oneBdrm" })

const amiChartOne = await this.amiChartRepository.save(tritonAmiChart)
const amiChartTwo = await this.amiChartRepository.save(getDefaultAmiChart())

const property = await this.propertyRepository.save({
...getDefaultProperty(),
})

const unitsToBeCreated: Array<Omit<UnitCreateDto, keyof BaseEntity>> = getDefaultUnits().map(
(unit, index) => {
return {
...unit,
property: {
id: property.id,
},
amiChart: index % 2 === 0 ? amiChartOne : amiChartTwo,
}
}
)

unitsToBeCreated[0].unitType = unitTypeOneBdrm
unitsToBeCreated[1].unitType = unitTypeOneBdrm

await this.unitsRepository.save(unitsToBeCreated)

return await this.listingRepository.save({
...listing,
property: property,
name: "Test: Default, Multiple AMI",
})
}
}
2 changes: 1 addition & 1 deletion backend/core/src/seeds/listings/listing-triton-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BaseEntity, DeepPartial } from "typeorm"
import { Listing } from "../../listings/entities/listing.entity"
import { UnitStatus } from "../../units/types/unit-status-enum"

const tritonAmiChart: AmiChartCreateDto = {
export const tritonAmiChart: AmiChartCreateDto = {
name: "San Jose TCAC 2019",
items: [
{
Expand Down
Loading

0 comments on commit e041609

Please sign in to comment.