update current_landuse_group before return in removeBuildingUserVerifiedAttribute

This commit is contained in:
Ed Chalstrey 2022-05-05 15:29:48 +01:00
parent fb277309f1
commit adb4bfa904

View File

@ -96,6 +96,15 @@ export async function updateBuildingUserVerifiedAttribute(buildingId: number, us
export async function removeBuildingUserVerifiedAttribute(buildingId: number, userId: string, attribute: string) : Promise<null> { export async function removeBuildingUserVerifiedAttribute(buildingId: number, userId: string, attribute: string) : Promise<null> {
try { try {
if (attribute == 'current_landuse_group'){
await (db).none(
`UPDATE buildings
SET current_landuse_verified = FALSE
WHERE buildings.building_id = $1;
`,
[buildingId]
);
}
return await (db).none( return await (db).none(
`DELETE FROM `DELETE FROM
building_verification building_verification
@ -106,15 +115,6 @@ export async function removeBuildingUserVerifiedAttribute(buildingId: number, us
`, `,
[buildingId, userId, attribute] [buildingId, userId, attribute]
); );
if (attribute == 'current_landuse_group'){
await (db).none(
`UPDATE buildings
SET current_landuse_verified = FALSE
WHERE buildings.building_id = $1;
`,
[buildingId]
);
}
} catch(error) { } catch(error) {
throw new DatabaseError(error.detail); throw new DatabaseError(error.detail);
} }