Skip to content

Commit

Permalink
fix: add listing opportunity
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan committed Mar 11, 2024
1 parent 1ae4d24 commit ea7dd09
Show file tree
Hide file tree
Showing 17 changed files with 664 additions and 73 deletions.
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"dayjs": "~1.11.9",
"handlebars": "~4.7.8",
"jsonwebtoken": "~9.0.1",
"juice": "^9.1.0",
"lodash": "~4.17.21",
"node-polyglot": "~2.5.0",
"passport": "~0.6.0",
Expand Down
48 changes: 48 additions & 0 deletions api/prisma/migrations/03_0_external_listing/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ALTER TABLE
"applications" DROP COLUMN "income_vouchers",
ADD
COLUMN "income_vouchers" TEXT [];

ALTER TABLE
"demographics"
ADD
COLUMN "spoken_language" TEXT;

ALTER TABLE
"jurisdictions"
ADD
COLUMN "enable_listing_opportunity" BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE "external_listings" (
"id" UUID NOT NULL DEFAULT uuid_generate_v4(),
"assets" JSONB NOT NULL,
"household_size_min" INTEGER,
"household_size_max" INTEGER,
"units_available" INTEGER,
"application_due_date" TIMESTAMP(6),
"application_open_date" TIMESTAMP(6),
"name" TEXT NOT NULL,
"waitlist_current_size" INTEGER,
"waitlist_max_size" INTEGER,
"is_waitlist_open" BOOLEAN,
"status" TEXT NOT NULL,
"review_order_type" TEXT NOT NULL,
"closed_at" TIMESTAMP(6),
"updated_at" TIMESTAMP(6),
"published_at" TIMESTAMP(6),
"last_application_update_at" TIMESTAMP(6) DEFAULT '1970-01-01 00:00:00-07' :: timestamp with time zone,
"neighborhood" TEXT,
"reserved_community_type_name" TEXT,
"url_slug" TEXT NOT NULL,
"units_summarized" JSONB,
"images" JSONB,
"multiselect_questions" JSONB,
"jurisdiction" JSONB,
"reserved_community_type" JSONB,
"units" JSONB,
"building_address" JSONB,
"features" JSONB,
"utilities" JSONB,
CONSTRAINT "ExternalListing_pkey" PRIMARY KEY ("id")
);
Original file line number Diff line number Diff line change
@@ -1,51 +1,4 @@
ALTER TABLE
"applications" DROP COLUMN "income_vouchers",
ADD
COLUMN "income_vouchers" TEXT [];

ALTER TABLE
"demographics"
ADD
COLUMN "spoken_language" TEXT;

ALTER TABLE
"jurisdictions"
ADD
COLUMN "enable_listing_preferences" BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE "external_listings" (
"id" UUID NOT NULL DEFAULT uuid_generate_v4(),
"assets" JSONB NOT NULL,
"household_size_min" INTEGER,
"household_size_max" INTEGER,
"units_available" INTEGER,
"application_due_date" TIMESTAMP(6),
"application_open_date" TIMESTAMP(6),
"name" TEXT NOT NULL,
"waitlist_current_size" INTEGER,
"waitlist_max_size" INTEGER,
"is_waitlist_open" BOOLEAN,
"status" TEXT NOT NULL,
"review_order_type" TEXT NOT NULL,
"closed_at" TIMESTAMP(6),
"updated_at" TIMESTAMP(6),
"published_at" TIMESTAMP(6),
"last_application_update_at" TIMESTAMP(6) DEFAULT '1970-01-01 00:00:00-07' :: timestamp with time zone,
"neighborhood" TEXT,
"reserved_community_type_name" TEXT,
"url_slug" TEXT NOT NULL,
"units_summarized" JSONB,
"images" JSONB,
"multiselect_questions" JSONB,
"jurisdiction" JSONB,
"reserved_community_type" JSONB,
"units" JSONB,
"building_address" JSONB,
"features" JSONB,
"utilities" JSONB,
CONSTRAINT "ExternalListing_pkey" PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS combined_listings;

CREATE VIEW "combined_listings" AS (
SELECT
Expand All @@ -67,7 +20,14 @@ CREATE VIEW "combined_listings" AS (
l.updated_at,
l.last_application_update_at,
l.neighborhood,
rct.name as "reserved_community_type_name",
-- TODO add reserved community type name
jsonb_build_object('id', j.id, 'name', j.name) AS "jurisdiction",
CASE
WHEN rct.id IS NOT NULL THEN jsonb_build_object('name', rct.name, 'id', rct.id)
ELSE NULL
END AS "reserved_community_types",
-- TODO add reserved community types
units.json AS "units",
jsonb_build_object(
'city',
Expand Down Expand Up @@ -207,6 +167,7 @@ CREATE VIEW "combined_listings" AS (
GROUP BY
listing_id
) as imgs ON l.id = imgs.listing_id
LEFT JOIN reserved_community_types rct ON l.reserved_community_type_id = rct.id
)
UNION
(
Expand All @@ -229,16 +190,16 @@ UNION
"updated_at",
"last_application_update_at",
"neighborhood",
-- "reserved_community_type_name",
"reserved_community_type_name",
-- "url_slug",
-- "multiselect_questions",
-- "multiselect_questions",
"jurisdiction",
-- "reserved_community_type",
"reserved_community_type",
"units",
"building_address",
-- "features",
-- "features", commenting out for now as not being used
"images",
-- "utilities",
-- "utilities", commenting out for now as not being used
"units_summarized" -- null -- leasing_agents; not available in base view and probably not useful anyway
-- true
FROM
Expand Down
5 changes: 2 additions & 3 deletions api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,14 @@ view CombinedListings {
lastApplicationUpdateAt DateTime? @map("last_application_update_at") @db.Timestamp(6) @default(dbgenerated("'1970-01-01 00:00:00-07'::timestamp with time zone"))
neighborhood String?
listingsBuildingAddress Json? @map("listings_building_address")
// reservedCommunityTypeName String? @map("reserved_community_type_name")
reservedCommunityTypeName String? @map("reserved_community_type_name")
// urlSlug String @map("url_slug")
unitsSummarized Json? @map("units_summarized")
listingImages Json? @map("listing_images")
// multiselectQuestions Json? @map("multiselect_questions")
// jurisdiction Json?
// reservedCommunityType Json? @map("reserved_community_type")
reservedCommunityTypes Json? @map("reserved_community_types")
units Json?
// buildingAddress Json? @map("building_address")
// features Json?
// utilities Json?
Expand Down
1 change: 1 addition & 0 deletions api/prisma/seed-helpers/jurisdiction-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export const jurisdictionFactory = (
enableAccessibilityFeatures: true,
enableUtilitiesIncluded: true,
enableGeocodingPreferences: true,
enableListingOpportunity: false,
listingApprovalPermissions: listingApprovalPermissions || [],
});
25 changes: 25 additions & 0 deletions api/prisma/seed-helpers/translation-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,31 @@ const translations = (jurisdictionName?: string) => ({
'Use the following code to sign in to your %{jurisdictionName} account. This code will be valid for 5 minutes. Never share this code.',
singleUseCode: '%{singleUseCode}',
},
rentalOpportunity: {
subject: 'New rental opportunity',
intro: 'Rental opportunity at',
applicationsDue: 'Applications Due',
community: 'Community',
address: 'Address',
rent: 'Rent',
minIncome: 'Minimum Income',
maxIncome: 'Maximum Income',
lottery: 'Lottery Date',
studio: 'Studios',
oneBdrm: '1 Bedrooms',
twoBdrm: '2 Bedrooms',
threeBdrm: '3 Bedrooms',
fourBdrm: '4 Bedrooms',
fiveBdrm: '5 Bedrooms',
SRO: 'SROs',
viewButton: {
en: 'View listing & apply',
es: 'Ver listado y aplicar',
zh: '查看列表并申请',
vi: 'Xem danh sách và áp dụng',
tl: 'Tingnan ang listahan at mag-apply',
},
},
});

export const translationFactory = (
Expand Down
17 changes: 8 additions & 9 deletions api/prisma/seed-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
simplifiedDCMap,
} from './seed-helpers/map-layer-factory';
import { ValidationMethod } from '../src/enums/multiselect-questions/validation-method-enum';
import { randomNoun } from './seed-helpers/word-generator';

export const stagingSeed = async (
prismaClient: PrismaClient,
Expand All @@ -49,28 +48,28 @@ export const stagingSeed = async (
});
// add another jurisdiction
const additionalJurisdiction = await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Contra Costa'),
data: jurisdictionFactory('Contra Costa', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Marin'),
data: jurisdictionFactory('Marin', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Napa'),
data: jurisdictionFactory('Napa', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('San Mateo'),
data: jurisdictionFactory('San Mateo', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Santa Clara'),
data: jurisdictionFactory('Santa Clara', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Solano'),
data: jurisdictionFactory('Solano', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('Sonoma'),
data: jurisdictionFactory('Sonoma', [UserRoleEnum.admin]),
});
await prismaClient.jurisdictions.create({
data: jurisdictionFactory('San Francisco'),
data: jurisdictionFactory('San Francisco', [UserRoleEnum.admin]),
});
// create admin user
await prismaClient.userAccounts.create({
Expand Down
3 changes: 2 additions & 1 deletion api/src/modules/email.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
import { MailService } from '@sendgrid/mail';
import { EmailService } from '../services/email.service';
Expand All @@ -8,7 +9,7 @@ import { GoogleTranslateService } from '../services/google-translate.service';
import { SendGridService } from '../services/sendgrid.service';

@Module({
imports: [],
imports: [HttpModule],
controllers: [],
providers: [
EmailService,
Expand Down
Loading

0 comments on commit ea7dd09

Please sign in to comment.