-
Notifications
You must be signed in to change notification settings - Fork 0
Feat analytics filter #15
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
59ba268
feat(analytics): add os column
laxman-aqw 41c0dd0
removed an unnecessary migration file
laxman-aqw 4d98472
feat(analytics):add url filter endpoints and service
laxman-aqw 72fb87a
fix: addressed pr review changes
laxman-aqw bff9f3f
feat(analytics): updated types and analytic service
laxman-aqw 6e10a0c
Merge branch 'feat-url' into feat-analytics-filter
laxman-aqw d4d3332
feat(analytics): fixed getAnalytics service and controller
laxman-aqw 93bf6ba
fix: renamed timestampz to timestamp with time zone
laxman-aqw d3ebe52
re added not null in url_id in createanalytics table
laxman-aqw b7c8d8f
fix: add deleted_at column in user table
laxman-aqw dd3a235
fix: add deleted at in user entity
laxman-aqw 71b430f
fIX: fixed filter url analytics by start and end date
laxman-aqw 6f77960
FIX: modified get url analytics dto
laxman-aqw a8abace
Addressed pr review changes
laxman-aqw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,17 @@ | ||
| NODE_ENV=development | ||
| DB_PORT=5432 | ||
| DB_TYPE=postgres | ||
| DB_HOST=db | ||
| DB_USERNAME= | ||
| DB_PASSWORD= | ||
| DB_NAME=postgres | ||
| DB_LOGGING= | ||
| JWT_SECRET= | ||
| JWT_VERIFICATION_TOKEN_SECRET= | ||
| JWT_VERIFICATION_TOKEN_EXPIRATION_TIME=3600 | ||
| EMAIL_CONFIRMATION_URL= | ||
| EMAIL_SERVICE= | ||
| EMAIL_USER= | ||
| EMAIL_PASS= | ||
| ENCRYPTION_KEY= | ||
| REDIRECT_BASE_URL = |
This file contains hidden or 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,30 @@ | ||
| import { | ||
| Body, | ||
| Controller, | ||
| Get, | ||
| HttpCode, | ||
| HttpStatus, | ||
| Query, | ||
| Req, | ||
| UseGuards, | ||
| } from '@nestjs/common'; | ||
| import { FilterAnalyticsRequestData } from './dto/filter-analytics-request-data'; | ||
| import { AnalyticsService } from './analytics.service'; | ||
| import { AuthGuard } from 'src/auth/auth.guard'; | ||
| import type { RequestWithUser } from 'src/types/RequestWithUser'; | ||
|
|
||
| @Controller('analytics') | ||
| export class AnalyticsController { | ||
| constructor(private readonly analyticsService: AnalyticsService) {} | ||
|
|
||
| @UseGuards(AuthGuard) | ||
| @HttpCode(HttpStatus.OK) | ||
| @Get() | ||
| async filterUrlAnalytics( | ||
| @Query() query: FilterAnalyticsRequestData, | ||
| @Req() request: RequestWithUser, | ||
| ) { | ||
| const userId = request.decodedData.sub; | ||
| return this.analyticsService.getAnalytics(query, userId); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
| import { | ||
| IsDateString, | ||
| isDateString, | ||
| IsNotEmpty, | ||
| IsOptional, | ||
| } from 'class-validator'; | ||
| import { Transform } from 'class-transformer'; | ||
|
|
||
| export class FilterAnalyticsRequestData { | ||
| @IsOptional() | ||
| browser?: string | null; | ||
|
|
||
| @IsOptional() | ||
| device?: string | null; | ||
|
|
||
| @IsOptional() | ||
| groupByUrl?: boolean | null; | ||
|
|
||
| @IsOptional() | ||
| urlId?: string | null; | ||
|
|
||
| @IsOptional() | ||
| os?: string | null; | ||
|
|
||
| @IsOptional() | ||
| country?: string | null; | ||
|
|
||
| @IsOptional() | ||
| ip?: string | null; | ||
|
|
||
| @IsOptional() | ||
| @IsDateString() | ||
| @Transform(({ value }) => new Date(value).toUTCString(), { | ||
| toPlainOnly: true, | ||
| }) | ||
| startDate?: Date | null; | ||
|
|
||
| @IsOptional() | ||
| @IsDateString() | ||
| @Transform(({ value }) => new Date(value).toUTCString(), { | ||
| toPlainOnly: true, | ||
| }) | ||
| endDate?: Date | null; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,11 +7,12 @@ export class CreateAnalyticsTable1761545874535 implements MigrationInterface { | |
| "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | ||
| "url_id" uuid NOT NULL, | ||
| "redirected_at" timestamp with time zone DEFAULT NOW(), | ||
| "ip" VARCHAR(100) NOT NULL, | ||
| "country" VARCHAR(40) NOT NULL, | ||
| "device" VARCHAR(50) NOT NULL, | ||
| "browser" VARCHAR(40) NOT NULL, | ||
| "user_agent" VARCHAR(200) NOT NULL, | ||
| "ip" VARCHAR(100) , | ||
| "country" VARCHAR(40) , | ||
| "os" VARCHAR(40) , | ||
| "device" VARCHAR(50), | ||
| "browser" VARCHAR(40) , | ||
| "user_agent" VARCHAR(200), | ||
|
Collaborator
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. user agents might exceed 200 character limit |
||
| CONSTRAINT "fk_url_analytics" | ||
| FOREIGN KEY ("url_id") REFERENCES "urls" ("id") ON DELETE CASCADE | ||
| ); | ||
|
|
||
This file contains hidden or 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,17 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class RenameIpColumn1762158558309 implements MigrationInterface { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "url_analytics" | ||
| RENAME COLUMN "ip" TO "ip_address"; | ||
| `); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "url_analytics" | ||
| RENAME COLUMN "ip_address" TO "ip"; | ||
| `); | ||
| } | ||
| } |
This file contains hidden or 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 { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class RelengthUserAgent1762159175018 implements MigrationInterface { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "url_analytics" | ||
| ALTER COLUMN "user_agent" TYPE TEXT;`); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE "url_analytics" | ||
| ALTER COLUMN "user_agent" TYPE varchar(200);`); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what does that regex expression do? It's better to add in comment about it
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.
updated