Skip to content

Commit

Permalink
fix: add fields to ExportCourseDto and filter invite/test courses
Browse files Browse the repository at this point in the history
  • Loading branch information
apalchys committed Sep 16, 2024
1 parent f56219a commit d86e658
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nestjs/src/courses/courses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export class CoursesService {
relations: ['discipline'],
});

const data: ExportCourseDto[] = courses.map(course => new ExportCourseDto(course));
const data: ExportCourseDto[] = courses
.filter(course => course.alias !== 'test-course')
.filter(course => !course.inviteOnly)
.map(course => new ExportCourseDto(course));

if (this.configService.env === 'prod') {
this.s3.putObject({
Expand Down
4 changes: 4 additions & 0 deletions nestjs/src/courses/dto/export-course.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ export class ExportCourseDto {
constructor(course: Course) {
this.id = course.id;
this.name = course.name;
this.fullName = course.fullName;
this.startDate = course.startDate.toISOString();
this.endDate = course.endDate.toISOString();
this.alias = course.alias;
this.discipline = course.discipline ? { id: course.discipline.id, name: course.discipline.name } : null;
this.description = course.description;
this.descriptionUrl = course.descriptionUrl;
this.registrationEndDate = course.registrationEndDate.toISOString();
}

id: number;
name: string;
fullName: string;
alias: string;
description: string;
descriptionUrl: string;
discipline: { id: number; name: string } | null;
registrationEndDate: string;
startDate: string;
Expand Down

0 comments on commit d86e658

Please sign in to comment.