From e675458ca9fbb5155867d8b83aa24dd3cd1f16cd Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Thu, 2 Apr 2026 14:42:13 +0530 Subject: [PATCH] PM-4490 Add names and contact in bulk lookup --- .circleci/config.yml | 2 +- sql/reports/identity/users-by-handles.sql | 15 +++++++++++++++ src/reports/identity/dtos/identity-users.dto.ts | 3 +++ .../identity/identity-reports.controller.ts | 2 +- src/reports/identity/identity-reports.service.ts | 6 ++++++ src/reports/report-directory.data.ts | 2 +- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d065519..25f7c72 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,7 +66,7 @@ workflows: - develop - pm-1127_1 - PM-4305 - - PM-4491-fix + - PM-4490 # Production builds are exectuted only on tagged commits to the # master branch. diff --git a/sql/reports/identity/users-by-handles.sql b/sql/reports/identity/users-by-handles.sql index 6e547e5..be1985c 100644 --- a/sql/reports/identity/users-by-handles.sql +++ b/sql/reports/identity/users-by-handles.sql @@ -7,6 +7,9 @@ WITH input_handles AS ( SELECT ih.handle_input AS "handle", u.user_id AS "userId", + NULLIF(TRIM(mem."firstName"), '') AS "firstName", + NULLIF(TRIM(mem."lastName"), '') AS "lastName", + NULLIF(TRIM(ph.phone_number::text), '') AS "contactNumber", pe.address AS "email", COALESCE( NULLIF(BTRIM(mem."competitionCountryCode"), ''), @@ -24,6 +27,18 @@ LEFT JOIN LATERAL ( LIMIT 1 ) AS pe ON TRUE +LEFT JOIN LATERAL ( + SELECT p."number" AS phone_number + FROM members."memberPhone" AS p + WHERE p."userId" = u.user_id + AND NULLIF(TRIM(p."number"::text), '') IS NOT NULL + ORDER BY + (p."type" = 'HOME') DESC, + p."createdAt" DESC NULLS LAST, + p."id" ASC + LIMIT 1 +) AS ph + ON TRUE LEFT JOIN members."member" AS mem ON mem."userId" = u.user_id ORDER BY ih.ordinality; diff --git a/src/reports/identity/dtos/identity-users.dto.ts b/src/reports/identity/dtos/identity-users.dto.ts index cc7ddf6..70d2465 100644 --- a/src/reports/identity/dtos/identity-users.dto.ts +++ b/src/reports/identity/dtos/identity-users.dto.ts @@ -45,6 +45,9 @@ export class UsersByGroupQueryDto { export interface IdentityUserDto { userId: number | null; handle: string; + firstName: string | null; + lastName: string | null; + contactNumber: string | null; email: string | null; country: string | null; } diff --git a/src/reports/identity/identity-reports.controller.ts b/src/reports/identity/identity-reports.controller.ts index a009e76..a4692e0 100644 --- a/src/reports/identity/identity-reports.controller.ts +++ b/src/reports/identity/identity-reports.controller.ts @@ -90,7 +90,7 @@ export class IdentityReportsController { @ApiBearerAuth() @ApiOperation({ summary: - "Export user details (ID, handle, email, country) for a list of handles", + "Export user details (ID, handle, firstName, lastName, contactNumber, email, country) for a list of handles", }) @ApiConsumes("application/json", "multipart/form-data") @ApiBody({ diff --git a/src/reports/identity/identity-reports.service.ts b/src/reports/identity/identity-reports.service.ts index e9976b4..9521b1f 100644 --- a/src/reports/identity/identity-reports.service.ts +++ b/src/reports/identity/identity-reports.service.ts @@ -16,6 +16,9 @@ const SUPPORTED_HANDLES_UPLOAD_EXTENSIONS = new Set([".txt", ".csv"]); type UsersByHandlesRow = { userId: number | null; handle: string; + firstName: string | null; + lastName: string | null; + contactNumber: string | null; email: string | null; country: string | null; }; @@ -114,6 +117,9 @@ export class IdentityReportsService { return results.map((row) => ({ userId: row.userId, handle: row.handle, + firstName: row.firstName, + lastName: row.lastName, + contactNumber: row.contactNumber, email: row.email, country: alpha3ToCountryName(row.country) ?? row.country, })); diff --git a/src/reports/report-directory.data.ts b/src/reports/report-directory.data.ts index 5e91355..f72c6e5 100644 --- a/src/reports/report-directory.data.ts +++ b/src/reports/report-directory.data.ts @@ -431,7 +431,7 @@ const REGISTERED_REPORTS_DIRECTORY: RegisteredReportsDirectory = { identityPostReport( "Users by Handles", "/identity/users-by-handles", - "Export user ID, handle, email, and country for each supplied handle; unknown handles return empty fields", + "Export user ID, handle, firstName, lastName, contactNumber, email, and country for each supplied handle; unknown handles return empty fields", AppScopes.Identity.UsersByHandles, [handlesBodyParam], ),