Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Fix #46 UNILAB usando metodo Promise.all
Browse files Browse the repository at this point in the history
  • Loading branch information
Diassisfilho committed Jan 17, 2024
1 parent ba8af72 commit c6b7679
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/courses/sigaa-course-student.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,21 @@ export class SigaaCourseStudent implements CourseStudent {
throw new Error('SIGAA: Invalid course page status code.');

let pageCourseCode: string | undefined;

const relatorioH3 = page.$('#relatorio h3').html();
const linkCodigoTurma = page.$('#linkCodigoTurma').html();

if (buttonLabel === 'Ver Notas') {
if (relatorioH3) {
pageCourseCode = this.parser.removeTagsHtml(relatorioH3).split(' - ')[0];
} else if (linkCodigoTurma){
pageCourseCode = this.parser.removeTagsHtml(linkCodigoTurma).replace(/ -$/, '');
if (page.bodyDecoded.includes('Ainda não foram')) {
pageCourseCode = this.parser
.removeTagsHtml(page.$('#linkCodigoTurma').html())
.replace(/ -$/, '');
} else {
pageCourseCode = this.parser
.removeTagsHtml(page.$('#relatorio h3').html())
.split(' - ')[0];
}
} else {
if (linkCodigoTurma) {
pageCourseCode = this.parser.removeTagsHtml(linkCodigoTurma).replace(/ -$/, '');
}
}

if (!pageCourseCode) {
throw new Error('SIGAA: Course code not found on the page.');
pageCourseCode = this.parser
.removeTagsHtml(page.$('#linkCodigoTurma').html())
.replace(/ -$/, '');
}

if (pageCourseCode !== this.code) {
Expand Down Expand Up @@ -1098,12 +1095,7 @@ export class SigaaCourseStudent implements CourseStudent {
}
}

if (
!username ||
!email ||
!registration ||
!program
)
if (!username || !email || !registration || !program)
throw new Error('SIGAA: Invalid student format at member page.');

const name = this.parser.removeTagsHtml(
Expand Down Expand Up @@ -1153,7 +1145,8 @@ export class SigaaCourseStudent implements CourseStudent {
const grades: GradeGroup[] = [];

const page = await this.getCourseSubMenu('Ver Notas', retry);
if (page.bodyDecoded.includes('Ainda não foram lançadas notas.')) return grades;
if (page.bodyDecoded.includes('Ainda não foram lançadas notas.'))
return grades;

const getPositionByCellColSpan = (
ths: cheerio.Cheerio,
Expand Down

0 comments on commit c6b7679

Please sign in to comment.