generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dashboard statistics and get all boards with pagination (#125)
- Loading branch information
1 parent
bdc35f2
commit 1d569d6
Showing
21 changed files
with
412 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ConfigModule, ConfigService } from '@nestjs/config'; | ||
import { JwtModule } from '@nestjs/jwt'; | ||
import { | ||
JWT_ACCESS_TOKEN_SECRET, | ||
JWT_ACCESS_TOKEN_EXPIRATION_TIME, | ||
} from '../../libs/constants/jwt'; | ||
|
||
export const JwtRegister = JwtModule.registerAsync({ | ||
imports: [ConfigModule], | ||
inject: [ConfigService], | ||
useFactory: (configService: ConfigService) => ({ | ||
secret: configService.get(JWT_ACCESS_TOKEN_SECRET), | ||
signOptions: { | ||
expiresIn: `${configService.get(JWT_ACCESS_TOKEN_EXPIRATION_TIME)}s`, | ||
}, | ||
}), | ||
}); |
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,16 @@ | ||
import { IsNumber, Min, IsOptional } from 'class-validator'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class PaginationParams { | ||
@IsOptional() | ||
@Type(() => Number) | ||
@IsNumber() | ||
@Min(0) | ||
page?: number; | ||
|
||
@IsOptional() | ||
@Type(() => Number) | ||
@IsNumber() | ||
@Min(1) | ||
size?: number; | ||
} |
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
33 changes: 29 additions & 4 deletions
33
backend/src/modules/boards/applications/get.board.application.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 |
---|---|---|
@@ -1,20 +1,45 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { GetBoardApplicationInterface } from '../interfaces/applications/get.board.application.interface'; | ||
import { GetBoardService } from '../interfaces/services/get.board.service.interface'; | ||
import { BoardsAndPage } from '../interfaces/boards-page.interface'; | ||
import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; | ||
import { TYPES } from '../interfaces/types'; | ||
|
||
@Injectable() | ||
export class GetBoardApplication implements GetBoardApplicationInterface { | ||
constructor( | ||
@Inject(TYPES.services.GetBoardService) | ||
private getBoardService: GetBoardService, | ||
private getBoardService: GetBoardServiceInterface, | ||
) {} | ||
|
||
getAllBoards(userId: string) { | ||
return this.getBoardService.getAllBoards(userId); | ||
getUserBoardsOfLast3Months( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null> { | ||
return this.getBoardService.getUserBoardsOfLast3Months(userId, page, size); | ||
} | ||
|
||
getSuperAdminBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null> { | ||
return this.getBoardService.getSuperAdminBoards(userId, page, size); | ||
} | ||
|
||
getUsersBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null> { | ||
return this.getBoardService.getUsersBoards(userId, page, size); | ||
} | ||
|
||
getBoard(boardId: string, userId: string) { | ||
return this.getBoardService.getBoard(boardId, userId); | ||
} | ||
|
||
countBoards(userId: string) { | ||
return this.getBoardService.countBoards(userId); | ||
} | ||
} |
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
18 changes: 17 additions & 1 deletion
18
backend/src/modules/boards/interfaces/applications/get.board.application.interface.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 |
---|---|---|
@@ -1,10 +1,26 @@ | ||
import { LeanDocument } from 'mongoose'; | ||
import { BoardDocument } from '../../schemas/board.schema'; | ||
import { BoardsAndPage } from '../boards-page.interface'; | ||
|
||
export interface GetBoardApplicationInterface { | ||
getAllBoards(userId: string): Promise<LeanDocument<BoardDocument>[] | null>; | ||
getUserBoardsOfLast3Months( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getSuperAdminBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getUsersBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getBoard( | ||
boardId: string, | ||
userId: string, | ||
): Promise<LeanDocument<BoardDocument> | null>; | ||
countBoards(userId: string): Promise<number>; | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/modules/boards/interfaces/boards-page.interface.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,8 @@ | ||
import { LeanDocument } from 'mongoose'; | ||
import { BoardDocument } from '../schemas/board.schema'; | ||
|
||
export interface BoardsAndPage { | ||
boards: LeanDocument<BoardDocument>[]; | ||
hasNextPage: boolean; | ||
page: number; | ||
} |
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,33 @@ | ||
import { LeanDocument } from 'mongoose'; | ||
import { TeamUserDocument } from '../../teams/schemas/team.user.schema'; | ||
|
||
export type QueryType = { | ||
$and: ( | ||
| { | ||
isSubBoard: boolean; | ||
updatedAt?: { | ||
$gte: number; | ||
}; | ||
$or?: undefined; | ||
} | ||
| { | ||
$or: ( | ||
| { | ||
_id: { | ||
$in: LeanDocument<any>[]; | ||
}; | ||
team?: undefined; | ||
} | ||
| { | ||
team: { | ||
$in?: LeanDocument<TeamUserDocument>[]; | ||
$ne?: undefined | null; | ||
}; | ||
_id?: undefined; | ||
} | ||
)[]; | ||
isSubBoard?: undefined; | ||
updatedAt?: undefined; | ||
} | ||
)[]; | ||
}; |
20 changes: 18 additions & 2 deletions
20
backend/src/modules/boards/interfaces/services/get.board.service.interface.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 |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import { LeanDocument } from 'mongoose'; | ||
import { BoardDocument } from '../../schemas/board.schema'; | ||
import { BoardsAndPage } from '../boards-page.interface'; | ||
|
||
export interface GetBoardService { | ||
getAllBoards(userId: string): Promise<LeanDocument<BoardDocument>[] | null>; | ||
export interface GetBoardServiceInterface { | ||
getUserBoardsOfLast3Months( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getSuperAdminBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getUsersBoards( | ||
userId: string, | ||
page?: number, | ||
size?: number, | ||
): Promise<BoardsAndPage | null>; | ||
getBoardFromRepo( | ||
boardId: string, | ||
): Promise<LeanDocument<BoardDocument> | null>; | ||
getBoard( | ||
boardId: string, | ||
userId: string, | ||
): Promise<LeanDocument<BoardDocument> | null>; | ||
countBoards(userId: string): Promise<number>; | ||
} |
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
Oops, something went wrong.