Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:UniversityOfHelsinkiCS/oodikone in…
Browse files Browse the repository at this point in the history
…to trunk
  • Loading branch information
Rochet2 committed May 24, 2019
2 parents b8cb6f7 + bcd2053 commit 9604fdf
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ services/updater_scheduler/all_student_numbers.txt
services/updater_scheduler/debug.log
services/updater_scheduler/active_student_numbers.txt
services/oodikone2-backend/debug.log
datastore
datastore
services/updater_api/debug.log
7 changes: 2 additions & 5 deletions services/backend/updater_writer/updater/database_updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const updateAttainments = (studyAttainments, transaction) => studyAttainments.ma
creditTeachers.length > 0 && Promise.all(creditTeachers.map(cT => CreditTeacher.upsert(cT, { transaction })))
])
} catch (e) {
console.log(e)
console.log('attainment update failed', e)
}
})

Expand All @@ -61,12 +61,9 @@ const updateStudent = async (student) => {
await deleteStudentStudyrights(studentInfo.studentnumber, transaction) // this needs to be done because Oodi just deletes deprecated studyrights from students ( big yikes )

await Student.upsert(studentInfo, { transaction })
try {
await Promise.all(semesterEnrollments.map(SE =>
SemesterEnrollment.upsert(SE, { transaction })))
} catch(e) {
console.log(e)
}

if (studyAttainments) await Promise.all(updateAttainments(studyAttainments, transaction))

if (studyRights) await Promise.all(updateStudyRights(studyRights, transaction))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const attemptGetFor = async (url, attempts = 5) => {
attempt += 1
try {
response = await getUrl(url)
logger.info('requested url', { url, status: response.status })
logger.info('requested url', { url, success: response.status === 200 })
return response
} catch (error) {
if (attempt === attempts) {
Expand All @@ -63,7 +63,7 @@ console.log(process.env.NODE_ENV)
const getStudent = async studentNumber => {
const url = `${base_url}/students/${studentNumber}/info`
try {
const response = await getUrl(url)
const response = await attemptGetFor(url)
const data = response.data.data
return data
} catch (e) {
Expand Down
2 changes: 0 additions & 2 deletions services/updater_api/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ if (process.env.NODE_ENV !== 'test') {
transports.push(new winston.transports.File({ filename: 'debug.log' }))
}

transports.push(new winston.transports.Console({ level: 'debug' }))


const logger = winston.createLogger({ transports })

Expand Down
183 changes: 183 additions & 0 deletions services/updater_api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion services/updater_api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"lodash": "^4.17.11",
"moment": "^2.24.0",
"node-nats-streaming": "^0.2.2",
"nodemon": "^1.18.10"
"nodemon": "^1.18.10",
"winston": "^3.2.1",
"winston-log2gelf": "^2.0.4"
}
}

0 comments on commit 9604fdf

Please sign in to comment.