Skip to content

Commit

Permalink
Merge pull request #1133 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
✨Improved graph ✨ & ❗️ERROR HANDLING ❗️
  • Loading branch information
woltsu authored Jul 17, 2019
2 parents 04bb80a + a2f6fb6 commit d00e11e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class CreditAccumulationGraphHighCharts extends Component {
moment(c.date).isSameOrAfter(moment(date))
))

createTooltip = ({ points }) => {
createTooltip = (point) => {
const { students, language, translate } = this.props
const targetCourse = this.sortCoursesByDate(students[0].courses)
.find(c => c.course.code === points[0].key)
.find(c => c.course.code === point.key)

if (!targetCourse) return ''

Expand Down Expand Up @@ -131,12 +131,14 @@ class CreditAccumulationGraphHighCharts extends Component {
style: {
all: 'unset',
display: 'none'
}
},
split: false
} : {}

const options = {
plotOptions: {
series: {
findNearestPointBy: 'xy',
point: {
events: {
click() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const createOrUpdateCourseProviders = async data => {
const getStudent = async (studentnumber) => {
const api = await getAllStudentInformationFromApi(studentnumber)
if (api.student === null || api.student === undefined) {
throw new Error(`API returned ${api.student} for studentnumber ${studentnumber}.`)
const error = new Error(`API returned ${api.student} for studentnumber ${studentnumber}.`)
error.name = 'NO_STUDENT'
throw error
}
const studentInfo = await mapper.getStudentFromData(api.student, api.studyrights)
const [studyRights, studyAttainments, semesterEnrollments, courseEnrollments] = await Promise.all([
Expand Down
12 changes: 10 additions & 2 deletions services/updater_api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ const handleMessage = async (priority) => async (msg) => { // :d
msg.ack()
stan.publish('status', `${message}:FETCHED`, (err) => { if (err) console.log( 'STATUS PUBLISH FAILED', err) })
} else {
// TODO: check that its a valid studentnumber and just ack it if its not
data = await getStudent(message)
try {
data = await getStudent(message)
} catch (e) {
if (e.name === 'NO_STUDENT') {
msg.ack()
stan.publish('status', `${message}:NO_STUDENT`, (err) => { if (err) console.log( 'STATUS PUBLISH FAILED', err) })
}
console.log(e)
return
}
try {
// TODO: check that data is properly structured(?)
stan.publish(priority ? 'PriorityWrite' :'UpdateWrite' , JSON.stringify(data), (err, guid) => {
Expand Down

0 comments on commit d00e11e

Please sign in to comment.