-
Notifications
You must be signed in to change notification settings - Fork 0
Add new report for Topgear handles created #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| -- INPUTS: | ||
| -- $1 :: timestamptz -- startDate filter | ||
| SELECT | ||
| m.handle AS "Handle", | ||
| m."firstName" AS "First name", | ||
| m."lastName" AS "Last name", | ||
| m.email AS "Email address", | ||
| m."userId" AS "User ID", | ||
| u.create_date AS "User create date", | ||
| sso.sso_user_id AS "SSO user ID", | ||
| sso.sso_user_name AS "SSO user name", | ||
| sso.email AS "SSO email" | ||
| FROM members.member m | ||
| JOIN identity."user" u | ||
| ON u.user_id = m."userId"::numeric(10, 0) | ||
| AND u.create_date >= $1::timestamptz | ||
| LEFT JOIN LATERAL ( | ||
| SELECT | ||
| usl.sso_user_id, | ||
| usl.sso_user_name, | ||
| usl.email | ||
| FROM identity.user_sso_login usl | ||
| WHERE usl.user_id = m."userId"::numeric(10, 0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| ORDER BY | ||
| (usl.email ILIKE '%@wipro.com') DESC, | ||
| usl.provider_id | ||
| LIMIT 1 | ||
| ) sso ON TRUE | ||
| WHERE m.email ILIKE '%@wipro.com' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| ORDER BY u.create_date DESC NULLS LAST, m.handle; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,24 @@ export class TopgearReportsController { | |
| return this.reports.getTopgearHourly(); | ||
| } | ||
|
|
||
| @Get("topgear-handles") | ||
| @UseGuards(PermissionsGuard) | ||
| @Scopes(AppScopes.AllReports, AppScopes.TopgearHandles) | ||
| @ApiBearerAuth() | ||
| @ApiOperation({ | ||
| summary: "Return the Topgear handles report for Wipro email accounts", | ||
| }) | ||
| @ApiQuery({ | ||
| name: "startDate", | ||
| required: false, | ||
| type: Date, | ||
| description: | ||
| "Filter users created after this date (defaults to current date - 90 days)", | ||
| }) | ||
| getTopgearHandles(@Query("startDate") startDate?: string) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| return this.reports.getTopgearHandles({ startDate }); | ||
| } | ||
|
|
||
| @Get("challenge-stats-by-user") | ||
| @UseGuards(PermissionsGuard) | ||
| @Scopes(AppScopes.AllReports, AppScopes.TopgearChallengeStatsByUser) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,12 @@ export class TopgearReportsService { | |
| return this.db.query(query); | ||
| } | ||
|
|
||
| async getTopgearHandles(opts: { startDate?: string }) { | ||
| const startDate = parseOptionalDate(opts.startDate) ?? subDays(new Date(), 90); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const query = this.sql.load("reports/topgear/topgear-handles.sql"); | ||
| return this.db.query(query, [startDate.toISOString()]); | ||
| } | ||
|
|
||
| async getChallengeStatsByUser(opts: { | ||
| startDate?: string; | ||
| endDate?: string; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗
correctness]Casting
m."userId"tonumeric(10, 0)may lead to unexpected behavior ifm."userId"contains non-numeric characters or exceeds the precision. Consider ensuring thatm."userId"is always a valid numeric value or adjust the data type accordingly.