Skip to content

Commit

Permalink
Merge pull request #21 from DylanHojnoski/fix-instructor-link
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb authored Oct 26, 2024
2 parents adfb4c2 + c4f9c57 commit 9b16234
Show file tree
Hide file tree
Showing 11 changed files with 5,912 additions and 4,753 deletions.
5 changes: 3 additions & 2 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const FACULTY_PAGES = [
'https://www.mtu.edu/cs/department/people/',
'https://www.mtu.edu/chemistry/people-groups/faculty-staff/',
'https://www.mtu.edu/biomedical/people/faculty/',
'https://www.mtu.edu/cee/people/faculty-staff/',
'https://www.mtu.edu/cege/people/faculty-staff/',
'https://www.mtu.edu/ece/department/faculty/',
'https://www.mtu.edu/ef/department/faculty-staff/',
'https://www.mtu.edu/geo/department/faculty/',
Expand All @@ -20,5 +20,6 @@ export const FACULTY_PAGES = [
'https://www.mtu.edu/vpa/department/faculty/',
'https://www.mtu.edu/computing/applied-computing/faculty/',
'https://www.mtu.edu/business/people-groups/faculty-staff/',
'https://www.mtu.edu/forest/about/faculty-staff/'
'https://www.mtu.edu/forest/about/faculty-staff/',
'https://www.mtu.edu/psychology/people/'
];
11 changes: 8 additions & 3 deletions src/lib/faculty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ export const getAllFaculty = async (): Promise<IFaculty[]> => {

const $ = cheerio.load(body);

const department = trim($('.site-title span > a').text());
const department = trim($('.title span > a').text());

const people: IFaculty[] = [];

$('.person').each((_, element) => {
const node = $(element);

let name = trim(node.find('.personal > h2').text());
let nameElement = node.find('.personal h2 a');

if (nameElement.length === 0) {
nameElement = node.find('.personal h2');
}

let name = trim(nameElement.text());

// Remove any attributes after name
if (name.includes(',')) {
Expand Down
2 changes: 1 addition & 1 deletion test/faculty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('getAllFaculty() works correctly', async t => {
.get('/business/people-groups/faculty/')
.reply(200, await fs.promises.readFile('./test/resources/faculty-with-obfuscated-emails.html'))

.get('/cee/people/faculty-staff/')
.get('/cege/people/faculty-staff/')
.reply(200, await fs.promises.readFile('./test/resources/faculty-with-attributes.html'));

const people = await getAllFaculty();
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export const FACULTY_PAGES = [
'https://www.mtu.edu/cs/department/people/',
'https://www.mtu.edu/chemistry/people-groups/faculty-staff/',
'https://www.mtu.edu/business/people-groups/faculty/',
'https://www.mtu.edu/cee/people/faculty-staff/'
'https://www.mtu.edu/cege/people/faculty-staff/'
];
1,857 changes: 860 additions & 997 deletions test/resources/chemistry-faculty.html

Large diffs are not rendered by default.

2,624 changes: 1,336 additions & 1,288 deletions test/resources/cs-faculty.html

Large diffs are not rendered by default.

3,438 changes: 2,304 additions & 1,134 deletions test/resources/faculty-with-obfuscated-emails.html

Large diffs are not rendered by default.

Loading

0 comments on commit 9b16234

Please # to comment.