Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #38 from BenShelton/develop
Browse files Browse the repository at this point in the history
Scraping Fixes
  • Loading branch information
BenShelton authored Jan 28, 2019
2 parents 0accbd8 + f42b51e commit 0cb0e87
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions database/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const updateWeekType = async ({ weekID, type }) => {
const updatedMembers = []
switch (type) {
case WEEK_TYPES.assembly.value:
case WEEK_TYPES.memorial.value:
for (const [k, v] of Object.entries(week.assignments || {})) {
if (v) {
for (const field of ASSIGNEE_FIELDS) {
Expand Down
7 changes: 4 additions & 3 deletions database/scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export default function scrapeWOL (date) {
return rp({ uri, transform })
.then($ => {
// Check schedule is online first
if (!$('#p2').text()) throw new Error('Week not yet available')
const weeklyBibleReading = $('#p2 strong', 'header').text()
if (!weeklyBibleReading) throw new Error('Week not yet available')

// Load as much static information as possible
const update = {
scraped: true,
weeklyBibleReading: $('#p2').text(),
weeklyBibleReading,
songs: [
$('#p3').text().trim(),
$('#p3', '#section1').text().trim(),
$(paragraphSelector, '#section4').first().text().trim(),
$(paragraphSelector, '#section4').last().text().trim()
],
Expand Down
28 changes: 13 additions & 15 deletions src/components/Schedule/ScheduleWeek.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
<VProgressCircular v-else indeterminate color="primary" />
</VLayout>

<!-- Assembly/Memorial Week Display -->
<VLayout v-else-if="week.type === WEEK_TYPES.assembly.value || week.type === WEEK_TYPES.memorial.value" justify-center class="pa-3">
<VLayout class="pt-3" column align-center>
<VIcon large color="primary" v-text="week.type === WEEK_TYPES.assembly.value ? 'group' : 'public'" />
<p class="headline text-xs-center primary--text mt-3" v-text="week.type === WEEK_TYPES.assembly.value ? 'Assembly Week' : 'Memorial Week'" />
</VLayout>
</VLayout>

<!-- Unscraped Week Display -->
<VLayout v-else-if="!week.scraped" justify-center class="pa-3">
<VLayout v-if="week.unavailable" column align-center>
Expand Down Expand Up @@ -89,21 +97,11 @@
<VIcon color="error">
warning
</VIcon>
<p class="pt-3 text-xs-center error--text">
There was an error scraping this week's data (most likely because the information isn't available yet on WOL) if you believe this is a mistake contact support
</p>
</VLayout>
</VLayout>

<!-- Assembly Week Display -->
<VLayout v-else-if="week.type === WEEK_TYPES.assembly.value" justify-center class="pa-3">
<VLayout column align-center>
<VIcon large color="primary">
group
</VIcon>
<p class="headline text-xs-center primary--text mt-3">
Assembly Week
</p>
<div class="pt-3 text-xs-center error--text">
<p>There was an error scraping this week's data</p>
<p>This is most likely because the information isn't available yet on WOL, but may also be because of a special week such as the Memorial</p>
<p>If you believe this is a mistake please contact support</p>
</div>
</VLayout>
</VLayout>

Expand Down
3 changes: 2 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export const LANGUAGE_GROUPS = ['English', 'Portuguese']
export const WEEK_TYPES = {
normal: { label: 'Normal', value: 0 },
assembly: { label: 'Assembly', value: 1 },
coVisit: { label: 'CO Visit', value: 2 }
coVisit: { label: 'CO Visit', value: 2 },
memorial: { label: 'Memorial', value: 3 }
}
16 changes: 8 additions & 8 deletions src/plugins/pdfMake.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,15 @@ export function generateSchedule (weeks, month) {
const [, month, day] = date.split('-')
const titleDay = day.charAt(0) === '0' ? day.charAt(1) : day
const titleMonth = MONTHS[+month - 1]
stack.push({
text: `${titleDay} ${titleMonth} | WEEKLY BIBLE READING: ${weeklyBibleReading}`,
fontSize: 14,
bold: true
})
let titleText = `${titleDay} ${titleMonth}`
if (weeklyBibleReading) titleText += ` | WEEKLY BIBLE READING: ${weeklyBibleReading}`
stack.push({ text: titleText, fontSize: 14, bold: true })

// Just add a block of text for assembly weeks
if (type === WEEK_TYPES.assembly.value) {
if (type === WEEK_TYPES.assembly.value || type === WEEK_TYPES.memorial.value) {
const blockText = type === WEEK_TYPES.assembly.value ? 'Assembly Week' : 'Memorial Week'
stack.push({ text: 'No Meeting', fontSize: 32, bold: true, alignment: 'center', margin: [0, 132, 0, 12] })
stack.push({ text: 'Assembly Week', fontSize: 18, alignment: 'center', margin: [0, 0, 0, 132] })
stack.push({ text: blockText, fontSize: 18, alignment: 'center', margin: [0, 0, 0, 132] })
stack.push(createScheduleSeparator())
return
}
Expand Down Expand Up @@ -391,7 +390,8 @@ export function generateAssignmentSlips (weeks, month) {
const slips = []
const VALID_TYPES = ['bibleReading', 'initialCall', 'returnVisit', 'bibleStudy', 'studentTalk']
for (const week of weeks) {
const { assignments } = week
const { type, assignments } = week
if (type === WEEK_TYPES.assembly.value || type === WEEK_TYPES.memorial.value) continue
for (let i = 0; i <= 4; i++) {
// treat index 0 as the bibleReading, else extract a student talk
const talk = i === 0 ? assignments.bibleReading : assignments['studentTalk' + i]
Expand Down

0 comments on commit 0cb0e87

Please sign in to comment.