Skip to content

Commit

Permalink
perf($Exercise): refine parsing other exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Feb 10, 2020
1 parent 73b91e9 commit 0457d2e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/views/exrx-net/components/exercise.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<td>{{ item.bodyPartName }}</td>
<td>{{ item.link }}</td>
<td>
<v-btn>Parse and Save</v-btn>
<v-btn @click="parseAndSaveExerciseByBodyPart(item)">Parse and Save</v-btn>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -103,6 +103,10 @@ export default class Exercise extends Vue {
}
}
private mounted () {
this.loadingContent = true
}
async handleClickSaveExercise (): Promise<void> {
if (!this.formValidation) {
this.$toast.warning('Invalid concurrency!')
Expand Down Expand Up @@ -171,9 +175,14 @@ export default class Exercise extends Vue {
const exerciseListItem = exerciseContainerDom.find('li > a')
exerciseListItem.each((index, element) => {
const exerciseLinkSortedByMuscle = new ExerciseLinkSortedByMuscle()
exerciseLinkSortedByMuscle.link = HyperlinkUtil.restorePathToUrl(element.attribs.href)
exerciseLinkSortedByMuscle.exerciseName = cheerio.load(element)('a').text().trim()
specificMuscleExerciseLink.exerciseLinkList.push(exerciseLinkSortedByMuscle)
try {
exerciseLinkSortedByMuscle.link = HyperlinkUtil.restorePathToUrl(element.attribs.href)
exerciseLinkSortedByMuscle.exerciseName = cheerio.load(element)('a').text().trim()
specificMuscleExerciseLink.exerciseLinkList.push(exerciseLinkSortedByMuscle)
} catch (error) {
console.error('Error occurred when iterating exercise!', error)
console.error('Error element:', element)
}
})
result.push(specificMuscleExerciseLink)
console.info('getAndParseExerciseCategory result', result)
Expand Down Expand Up @@ -290,8 +299,9 @@ export default class Exercise extends Vue {
}
}
private mounted () {
this.loadingContent = true
async parseAndSaveExerciseByBodyPart (exerciseLinkSortedByBodyPart: ExerciseLinkSortedByBodyPart) {
const exercise = await this.getAndParseExerciseCategory(exerciseLinkSortedByBodyPart)
this.$toast.info(`exercise.length: ${exercise.length}`)
}
}
</script>
Expand Down

0 comments on commit 0457d2e

Please sign in to comment.