Skip to content

Commit

Permalink
fix PR & remove scraper folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mhd-hi committed Jul 29, 2024
1 parent 0f0d180 commit 84f24f6
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 106 deletions.
2 changes: 1 addition & 1 deletion src/common/api-helper/ets/course/ets-course.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export class EtsCourseController {
throw new Error('The id parameter is required');
}

return this.etsCourseService.fetchCoursesById('349682,349710');
return this.etsCourseService.fetchCoursesById(id);
}
}
2 changes: 1 addition & 1 deletion src/common/api-helper/ets/ets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class EtsController {
throw new Error('The id parameter is required');
}

return this.etsCourseService.fetchCoursesById('349682,349710');
return this.etsCourseService.fetchCoursesById(id);
}

@Get('programs')
Expand Down
19 changes: 0 additions & 19 deletions src/common/api-helper/ets/scraper/scraper.controller.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/common/api-helper/ets/scraper/scraper.module.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions src/common/api-helper/ets/scraper/services/scraper.service.ts

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { firstValueFrom } from 'rxjs';
import { CourseCodeValidationPipe } from '../../../../pipes/models/course/course-code-validation-pipe';
import { PdfParserUtil } from '../../../../utils/pdf/parser/pdfParserUtil';
import { TextExtractor } from '../../../../utils/pdf/parser/textExtractorUtil';
import { IPlanificationCours } from './planification-cours.types';
import { ICoursePlanification } from './planification-cours.types';
import { Row } from './Row';

@Injectable()
Expand All @@ -17,7 +17,9 @@ export class PlanificationCoursService {

constructor(private httpService: HttpService) {}

public async parsePdfFromUrl(pdfUrl: string): Promise<IPlanificationCours[]> {
public async parsePdfFromUrl(
pdfUrl: string,
): Promise<ICoursePlanification[]> {
try {
const response = await firstValueFrom(
this.httpService.get(pdfUrl, { responseType: 'arraybuffer' }),
Expand All @@ -34,7 +36,7 @@ export class PlanificationCoursService {
public parsePlanificationCoursPdf(
pdfBuffer: Buffer,
pdfUrl: string,
): Promise<IPlanificationCours[]> {
): Promise<ICoursePlanification[]> {
return PdfParserUtil.parsePdfBuffer(pdfBuffer, (pdfData) =>
this.processPdfData(pdfData, pdfUrl),
);
Expand All @@ -43,11 +45,11 @@ export class PlanificationCoursService {
public processPdfData(
pdfData: Output,
pdfUrl: string,
): IPlanificationCours[] {
): ICoursePlanification[] {
try {
const headerCells: Row[] = this.parseHeaderCells(pdfData);
const courses: IPlanificationCours[] = [];
let currentCourse: IPlanificationCours = this.initializeCourse();
const courses: ICoursePlanification[] = [];
let currentCourse: ICoursePlanification = this.initializeCourse();

pdfData.Pages.forEach((page: Page) => {
page.Texts.forEach((textItem: Text) => {
Expand Down Expand Up @@ -97,7 +99,7 @@ export class PlanificationCoursService {
}
}

private initializeCourse(): IPlanificationCours {
private initializeCourse(): ICoursePlanification {
return {
code: '',
available: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface IPlanificationCours {
export interface ICoursePlanification {
code: string;
available: Record<string, string>;
}
4 changes: 2 additions & 2 deletions src/common/website-helper/pdf/pdf.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ERROR_MESSAGES } from '../../constants/error-messages';
import { HoraireCoursService } from './pdf-parser/horaire/horaire-cours.service';
import { IHoraireCours } from './pdf-parser/horaire/horaire-cours.types';
import { PlanificationCoursService } from './pdf-parser/planification/planification-cours.service';
import { IPlanificationCours } from './pdf-parser/planification/planification-cours.types';
import { ICoursePlanification } from './pdf-parser/planification/planification-cours.types';

@Controller('pdf')
export class PdfController {
Expand Down Expand Up @@ -46,7 +46,7 @@ export class PdfController {
@Get('planification-cours')
public async parsePlanificationCoursPdf(
@Query('program') programCode: string,
): Promise<IPlanificationCours[]> {
): Promise<ICoursePlanification[]> {
if (!programCode) {
throw new HttpException(
ERROR_MESSAGES.REQUIRED_PDF_URL,
Expand Down

0 comments on commit 84f24f6

Please sign in to comment.