Skip to content

Commit

Permalink
fix: update model
Browse files Browse the repository at this point in the history
  • Loading branch information
apalchys committed Jan 18, 2024
1 parent 3342145 commit 47e906c
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 3,135 deletions.
125 changes: 125 additions & 0 deletions client/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,37 @@ export interface Education {
*/
'graduationYear': number;
}
/**
*
* @export
* @interface EndorsementDataDto
*/
export interface EndorsementDataDto {
/**
*
* @type {EndorsementUserDto}
* @memberof EndorsementDataDto
*/
'user': EndorsementUserDto;
/**
* User\'s courses
* @type {Array<CourseDto>}
* @memberof EndorsementDataDto
*/
'courses': Array<CourseDto>;
/**
* Number of students
* @type {number}
* @memberof EndorsementDataDto
*/
'studentsCount': number;
/**
* Number of interviews
* @type {number}
* @memberof EndorsementDataDto
*/
'interviewsCount': number;
}
/**
*
* @export
Expand All @@ -2586,6 +2617,37 @@ export interface EndorsementDto {
*/
'data': object | null;
}
/**
*
* @export
* @interface EndorsementUserDto
*/
export interface EndorsementUserDto {
/**
*
* @type {number}
* @memberof EndorsementUserDto
*/
'id': number;
/**
*
* @type {string}
* @memberof EndorsementUserDto
*/
'githubId': string;
/**
*
* @type {string}
* @memberof EndorsementUserDto
*/
'firstName': string;
/**
*
* @type {string}
* @memberof EndorsementUserDto
*/
'lastName': string;
}
/**
*
* @export
Expand Down Expand Up @@ -13559,6 +13621,39 @@ export const ProfileApiAxiosParamCreator = function (configuration?: Configurati



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {string} username
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getEndorsementData: async (username: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'username' is not null or undefined
assertParamExists('getEndorsementData', 'username', username)
const localVarPath = `/profile/{username}/endorsement-data`
.replace(`{${"username"}}`, encodeURIComponent(String(username)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -13790,6 +13885,16 @@ export const ProfileApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getEndorsement(username, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {string} username
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getEndorsementData(username: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EndorsementDataDto>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getEndorsementData(username, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {string} username
Expand Down Expand Up @@ -13869,6 +13974,15 @@ export const ProfileApiFactory = function (configuration?: Configuration, basePa
getEndorsement(username: string, options?: any): AxiosPromise<EndorsementDto> {
return localVarFp.getEndorsement(username, options).then((request) => request(axios, basePath));
},
/**
*
* @param {string} username
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getEndorsementData(username: string, options?: any): AxiosPromise<EndorsementDataDto> {
return localVarFp.getEndorsementData(username, options).then((request) => request(axios, basePath));
},
/**
*
* @param {string} username
Expand Down Expand Up @@ -13944,6 +14058,17 @@ export class ProfileApi extends BaseAPI {
return ProfileApiFp(this.configuration).getEndorsement(username, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @param {string} username
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ProfileApi
*/
public getEndorsementData(username: string, options?: AxiosRequestConfig) {
return ProfileApiFp(this.configuration).getEndorsementData(username, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @param {string} username
Expand Down
50 changes: 45 additions & 5 deletions nestjs/src/profile/dto/endorsement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Feedback } from '@entities/feedback';
import { Mentor } from '@entities/mentor';
import { User } from '@entities/user';
import { ApiProperty } from '@nestjs/swagger';
import { CourseDto } from 'src/courses/dto';

type Data = {
user: User;
Expand All @@ -13,6 +14,39 @@ type Data = {
feedbacks: Feedback[];
};

class EndorsementUserDto {
constructor(user: User) {
this.id = user.id;
this.githubId = user.githubId;
this.firstName = user.firstName;
this.lastName = user.lastName;
}
@ApiProperty({ type: Number })
public readonly id: number;

@ApiProperty({ type: String })
public readonly githubId: string;

@ApiProperty({ type: String })
public readonly firstName: string;

@ApiProperty({ type: String })
public readonly lastName: string;
}

class FeedbackDto {
constructor(feedback: Feedback) {
this.id = feedback.id;
this.comment = feedback.comment;
}

@ApiProperty({ type: Number })
public readonly id: number;

@ApiProperty({ type: String })
public readonly comment: string | null;
}

export class EndorsementDto {
constructor(profile: { content: string; data: object } | null) {
this.summary = profile?.content ?? 'We do not have enough data to generate endorsement.';
Expand All @@ -29,17 +63,23 @@ export class EndorsementDto {
export class EndorsementDataDto {
constructor(data: Data) {
this.user = data.user;
this.courses = data.courses;
this.mentors = data.mentors;
this.courses = data.courses.map(course => new CourseDto(course));
this.studentsCount = data.studentsCount;
this.interviewsCount = data.interviewsCount;
this.feedbacks = data.feedbacks;
}

@ApiProperty({ type: EndorsementUserDto })
public user: User;
public courses: Course[];
public mentors: Mentor[];

@ApiProperty({ type: CourseDto, isArray: true, description: `User's courses` })
public courses: CourseDto[];

@ApiProperty({ type: Number, description: `Number of students` })
public studentsCount: number;

@ApiProperty({ type: Number, description: `Number of interviews` })
public interviewsCount: number;
public feedbacks: Feedback[];

public feedbacks: FeedbackDto[];
}
2 changes: 1 addition & 1 deletion nestjs/src/profile/profile.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class ProfileController {

@Get(':username/endorsement-data')
@ApiOperation({ operationId: 'getEndorsementData' })
@ApiResponse({ type: EndorsementDto })
@ApiResponse({ type: EndorsementDataDto })
@UseGuards(DefaultGuard)
public async getEndorsementData(@Param('username') githubId: string) {
const data = await this.endormentService.getEndorsmentData(githubId);
Expand Down
Loading

0 comments on commit 47e906c

Please sign in to comment.