forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new cron job for duplicates (bloom-housing#4230) (#766)
* feat: new cron job for duplicates (bloom-housing#4230) * fix: add duplicates view * fix: new cron job for duplicates * fix: multiple names flagged usecase * fix: bugs found in qa * fix: better way to connect listings * fix: clean up imports in listing service * fix: alternative way of duplicate grouping * fix: qa fixes * fix: add afs last run timestamp * fix: add additional test * fix: move type * fix: pr fixes * fix: change name of enum to combination * fix: cleanup test * fix: make lottery test more consistent * fix: update to a higher migration number * fix: switch to concat * fix: lottery merge conflicts * fix: remove missed merge conflict --------- Co-authored-by: Jared White <[email protected]>
- Loading branch information
1 parent
d850244
commit 10c7233
Showing
17 changed files
with
3,630 additions
and
1,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
api/prisma/migrations/17_add_duplicates_view/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
CREATE VIEW "application_flagged_set_possibilities" AS ( | ||
SELECT | ||
CONCAT( | ||
LOWER(a.first_name), | ||
'-', | ||
LOWER(a.last_name), | ||
'-', | ||
a.birth_month, | ||
'-', | ||
a.birth_day, | ||
'-', | ||
a.birth_year | ||
) as "key", | ||
app.listing_id, | ||
app.id as "application_id", | ||
'nameAndDOB' as "type" | ||
FROM | ||
applicant a, | ||
applications app | ||
WHERE | ||
a.id = app.applicant_id | ||
and app.deleted_at is null | ||
) | ||
UNION | ||
( | ||
SELECT | ||
a.email_address as "key", | ||
app.listing_id, | ||
app.id as "application_id", | ||
'email' as "type" | ||
FROM | ||
applications app, | ||
applicant a | ||
WHERE | ||
a.id = app.applicant_id | ||
and a.email_address is not null | ||
and app.deleted_at is null | ||
) | ||
UNION | ||
( | ||
SELECT | ||
CONCAT( | ||
LOWER(hm.first_name), | ||
'-', | ||
LOWER(hm.last_name), | ||
'-', | ||
hm.birth_month, | ||
'-', | ||
hm.birth_day, | ||
'-', | ||
hm.birth_year | ||
) as "key", | ||
app.listing_id, | ||
app.id as "application_id", | ||
'nameAndDOB' as "type" | ||
FROM | ||
applications app, | ||
household_member hm | ||
WHERE | ||
hm.application_id = app.id | ||
and app.deleted_at is null | ||
); | ||
|
||
ALTER TYPE "rule_enum" | ||
ADD | ||
VALUE 'combination'; | ||
|
||
ALTER TABLE | ||
application_flagged_set DROP CONSTRAINT IF EXISTS "application_flagged_set_rule_key_key"; | ||
|
||
DROP INDEX IF EXISTS "application_flagged_set_rule_key_key"; | ||
|
||
CREATE UNIQUE INDEX "application_flagged_set_rule_key_listing_id_key" ON "application_flagged_set"("rule_key", "listing_id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ import { | |
simplifiedDCMap, | ||
} from './seed-helpers/map-layer-factory'; | ||
import { ValidationMethod } from '../src/enums/multiselect-questions/validation-method-enum'; | ||
import { householdMemberFactorySingle } from './seed-helpers/household-member-factory'; | ||
|
||
export const stagingSeed = async ( | ||
prismaClient: PrismaClient, | ||
|
@@ -505,18 +506,131 @@ export const stagingSeed = async ( | |
}, | ||
], | ||
multiselectQuestions: [cityEmployeeQuestion], | ||
// has applications that are the same email | ||
// has applications that are the same email and also same name/dob | ||
applications: [ | ||
await applicationFactory(), | ||
await applicationFactory(), | ||
await applicationFactory({ | ||
applicant: { emailAddress: '[email protected]' }, | ||
submissionType: ApplicationSubmissionTypeEnum.paper, | ||
}), | ||
await applicationFactory({ | ||
applicant: { emailAddress: '[email protected]' }, | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first', | ||
lastName: 'last', | ||
birthDay: 1, | ||
birthMonth: 1, | ||
birthYear: 1970, | ||
}, | ||
}), | ||
await applicationFactory(), | ||
await applicationFactory(), | ||
await applicationFactory({ | ||
submissionType: ApplicationSubmissionTypeEnum.paper, | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first2', | ||
lastName: 'last2', | ||
birthDay: 2, | ||
birthMonth: 2, | ||
birthYear: 1992, | ||
}, | ||
}), | ||
await applicationFactory({ | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first2', | ||
lastName: 'last2', | ||
birthDay: 2, | ||
birthMonth: 2, | ||
birthYear: 1992, | ||
}, | ||
}), | ||
await applicationFactory({ | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first', | ||
lastName: 'last', | ||
birthDay: 1, | ||
birthMonth: 1, | ||
birthYear: 1970, | ||
}, | ||
}), | ||
await applicationFactory({ | ||
applicant: { emailAddress: '[email protected]' }, | ||
}), | ||
await applicationFactory({ | ||
applicant: { emailAddress: '[email protected]' }, | ||
}), | ||
await applicationFactory({ | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first3', | ||
lastName: 'last3', | ||
birthDay: 1, | ||
birthMonth: 1, | ||
birthYear: 1970, | ||
}, | ||
householdMember: [ | ||
householdMemberFactorySingle(1, { | ||
firstName: 'householdFirst1', | ||
lastName: 'householdLast1', | ||
birthDay: 5, | ||
birthMonth: 5, | ||
birthYear: 1950, | ||
}), | ||
householdMemberFactorySingle(2, { | ||
firstName: 'householdFirst2', | ||
lastName: 'householdLast2', | ||
birthDay: 8, | ||
birthMonth: 8, | ||
birthYear: 1980, | ||
}), | ||
], | ||
}), | ||
await applicationFactory({ | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first3', | ||
lastName: 'last3', | ||
birthDay: 1, | ||
birthMonth: 1, | ||
birthYear: 1970, | ||
}, | ||
householdMember: [ | ||
householdMemberFactorySingle(1, { | ||
firstName: 'householdFirst1', | ||
lastName: 'householdLast1', | ||
birthDay: 5, | ||
birthMonth: 5, | ||
birthYear: 1950, | ||
}), | ||
householdMemberFactorySingle(2, { | ||
firstName: 'householdFirst2', | ||
lastName: 'householdLast2', | ||
birthDay: 8, | ||
birthMonth: 8, | ||
birthYear: 1980, | ||
}), | ||
], | ||
}), | ||
await applicationFactory({ | ||
applicant: { | ||
emailAddress: '[email protected]', | ||
firstName: 'first4', | ||
lastName: 'last4', | ||
birthDay: 2, | ||
birthMonth: 2, | ||
birthYear: 2002, | ||
}, | ||
}), | ||
await applicationFactory({ | ||
householdMember: [ | ||
{ | ||
firstName: 'first4', | ||
lastName: 'last4', | ||
birthDay: 2, | ||
birthMonth: 2, | ||
birthYear: 2002, | ||
}, | ||
], | ||
}), | ||
], | ||
}, | ||
|
@@ -710,7 +824,7 @@ export const stagingSeed = async ( | |
customMapPin: false, | ||
contentUpdatedAt: dayjs(new Date()).subtract(1, 'days').toDate(), | ||
publishedAt: dayjs(new Date()).subtract(3, 'days').toDate(), | ||
closedAt: dayjs(new Date()).subtract(1, 'days').toDate(), | ||
closedAt: dayjs(new Date()).subtract(5, 'days').toDate(), | ||
listingsApplicationPickUpAddress: undefined, | ||
listingsLeasingAgentAddress: undefined, | ||
listingsApplicationDropOffAddress: undefined, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
api/src/dtos/application-flagged-sets/afs-process-query-params.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { Expose } from 'class-transformer'; | ||
import { IsUUID } from 'class-validator'; | ||
import { ValidationsGroupsEnum } from '../../enums/shared/validation-groups-enum'; | ||
|
||
export class AfsProcessQueryParams { | ||
@Expose() | ||
@ApiPropertyOptional() | ||
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] }) | ||
listingId?: string; | ||
|
||
@Expose() | ||
@ApiPropertyOptional() | ||
force?: boolean; | ||
} |
Oops, something went wrong.