Skip to content

Commit

Permalink
Fix failure when parsing inquiries
Browse files Browse the repository at this point in the history
  • Loading branch information
zieren committed Nov 17, 2022
1 parent 5c12658 commit 858d41d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,14 @@ function buildEmailsForThreads(teachers, processedThreads, emails) {
async function readInquiries(page) {
await page.goto(CONFIG.elternportal.url + '/meldungen/kommunikation');
const inquiries = await page.$$eval(
'h3.panel-title', (headings) => headings.map((h) => {
'div.panel', (panels) => panels.map(p => {
return {
subject: h.textContent.trim().replace(/\(Beantwortet\) (?=\d\d\.\d\d\.\d\d\d\d)/, '')
subject: p.querySelector('h3.panel-title')
.textContent.trim().replace(/\(Beantwortet\) (?=\d\d\.\d\d\.\d\d\d\d)/, ''),
messages: Array.from(p.querySelector('div.panel-body').childNodes)
.filter(n => n.nodeName === '#text').map(n => n.textContent)
};
}));
for (let i = 0; i < inquiries.length; ++i) {
inquiries[i].messages = await page.$eval('div#bear_' + i,
(div) => Array.from(div.firstElementChild.childNodes)
.filter(c => c.nodeName === '#text')
.map(c => c.textContent));
}
LOG.info('Found %d inquiries', inquiries.length);
// Order is reverse chronological, make it forward.
return inquiries.reverse();
Expand Down

0 comments on commit 858d41d

Please sign in to comment.